Server side javascript in XPages is very difficult to debug. XPages lab is aware of that and try to figure out a solution. OpenNTF has lots of tools and recommendations for debugging.

However, sometimes error messages make me crazy! Here is an example...

I am developing an XPages project and I worked on SSJS persistence and scope issues a lot.

Yesterday, in the middle of night, I had a stupid problem in my code.

function getDoc(someParams) { 
   // ... do something ... //
   return someDoc;

function setSomeValue(value) {
  doc.replaceItemValue("someField", value);
  doc.computeWithForm(false, false);
  if(!, false)) {
     // ... do some logging stuff ... //

It's a simple code. Get some document and set some fields and save... However, it sometimes throws an error like this:

Error while executing JavaScript action expression
Script interpreter error, line€, col=26: [TypeError] Exception occurred calling method, boolean) null

The error is coming from "" method. But the error message is interesting. There is a "TypeError" here. So I put 'print's everywhere in my code to determine if 'doc' object is fine. No solution... It also says null. Again a number of 'print's, no hope! I removed functions and put my code directly into a button, no hope! It doesn't work...

Then I noticed the problem. I was testing the code with anonymous user and it doesn't have authorization!!! The error should be "You are not authorized to do that". Or maybe it should not throw an error and just return false (I am not sure about the last one because there wouldn't any chance to know exact problem in this case).

Dealing with high level problems like SSJS persistence and scope issues have prevented me to think simple.

Anyway, the lesson of the day is 'Think simple while debugging. Eliminate the most obvious reasons before ripping your nice code...
Serdar Basegmez   |   June 24 2011 09:46:51 AM   |    Development  Tips  XPages    |  
  |   Next   |   Previous

Comments (6)

Gravatar Image
Randal Oulton       01/15/2013 12:49:41 AM


I was getting some nulls (thanks Tom) -- got those dealt with....

then still problem even after checking access control all looked good -- but then aha! turned out to be, maximum internet access on the database was set to reader! Had to raise that.

Thanks for clues everybody!

Gravatar Image
shafi       08/31/2012 1:34:43 PM

Thanks alot

Gravatar Image
Serdar Basegmez    02/17/2012 6:21:40 PM


Thank you... The largest portion of my visitors are coming from Google and this is a still-popular thread :)

Gravatar Image
Tom Sparrow       02/17/2012 6:17:38 PM

I know this is an old thread, but just because it's so high on the rankings for a search on this problem I thought I'd add my experience in anyway.

Had the same problem (initially) with no access, but the problem wouldn't go away. After a half a day digging around my code, it turned out that the problem was a single field in the document that had a null pushed into it.

For some reason, it happily poked the null into the field and then failed to save several lines south.

The really odd thing (given this was a save operation on a new document) was the stack trace showed 'Note cannot be deleted' as a key error message.

Anyway, one more thing to check for anyone finding a similar problem.

Gravatar Image
Stephan H. Wissel    06/25/2011 8:54:53 PM

In our XPages class I gloss over the ACL and thus the deletion of a record fails (default no delete). So participants struggle a little but sooner or later figure it out. That struggle anchors the attention to access rights.

Gravatar Image
Jason [Hook]       06/24/2011 12:39:15 PM

We've always had to think a bit laterally when designing with Notes :-)

Thank you for the tip. I think I've seen the same problem with my managed beans when they've been used after a session has timed out.