Thursday, November 4, 2010

XPages: Obscure error message for undeclared variable

I've had an error message that popped up regularly in our logs. Script interpreter error, line=524, col=25: Interpret exception
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 ){ .. }


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.

Unknown said...

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

Anonymous said...

"Notes is silly some times."

Notes is basically stupid most of the time!