Thursday, November 4, 2010

XPages: Obscure error message for undeclared variable

I've had an error message that popped up regularly in our logs.
com.ibm.jscript.InterpretException: Script interpreter error, line=524, col=25: Interpret exception
at com.ibm.xsp.javascript.AbstractLocalObject.put(AbstractLocalObject.java:95)
The line it refers to has a for .. in loop on a scoped variable. I believed it had to do with the object being in a scoped variable, and tried to make a by-value copy. That didn't help.

I finally (!!) discovered the reason for the error message. I had forgotten to declare the "key" variable.
// Results in error
for( key in object ){ .. }
// OK (key can also be declared outside loop)
for( var key in object ){ .. }

3 comments:

Anonymous said...

2 people for 2 hours looking at an xpage that would not load up from a url but works from a simple action Open Page... and then I find this article.

Notes is silly some times.

Thanks for the post.

Nachiket Bhandarkar said...

Thanks for the post this really helped...!!!

Anonymous said...

"Notes is silly some times."

Notes is basically stupid most of the time!