Tag Archives: SSJS

view.postscript the connection between backend and frontend JS

Have you ever needed to call a client script after you run some some serverside code.

The answer is view.postScript=”your client side function” this function is available from 8.5.3

The code in view.postScript will be sent back to the browser and executed like onComplete but you can control it from SSJS. Great news or what do you think?

What can I use this for you might ask .

1. Change UI design when the partial refresh has brought up new data

2. If you have a multi window solution use the script to update parent window or close the current

3. Depending of the result do a secondary partial refresh on a case selected panel

If you already used view.postscript, please write a comment about your use case. 

XPages SSJS will run forever if you let it

If you add some code behind a button, and a user clicks that button. This code will run until it’s finished no matter what you do.

var LoopBreak=0;var x=0
var thing=1
var now=@Text(@Now())
var nownow=""
for(x=0;x<10000;x++){ nownow=@Text(@Now()) } if(LoopBreak>30){

If you place the code above behind a button on an XPage.

(Of couse at your own risk, and not on a production server)

Open the XPage in a webbrowser, also open up so you can watch the server console in realtime.

Click on the button and close the browser window directly afterwards, and watch the server console.

The code will continue to run until it’s done, imagine what will happen if you remove the line LoopBreak++  you will get a infinite loop.

And the CPU of your server will boost up to 100% and you will not be able to stop your Domino server with out killing it.

So my tip to you is to always have a fail safe, a loop breaker for your loops.

Create your own @Formula

There is several ways of creating your own @Formula commands. One easy way is to create a serverside scriptlibrary and create a function that is named @MyCommand there. Include this SSJS library into your XPage / Custom Control and you have added a custom @Formula.

function @Getfirstword(data){

   return @Left(data,” “)


And the second way is to create your own extension to the Domino designer as Ulrich Krause has done in this new openntf project.


There is probably serveral more ways of adding new @ commands to XPages, if you know a way make a comment.