Reputation: 134
I am trying to put some SSJS code together in which I'd like to check, if currentDocument is available.
I've tried something like:
if(currentDocument != undefined)
But it just throws a runtime error.
Is it even possible to check if currentDocument is available?
Any help would be greatly appreciated.
Upvotes: 0
Views: 229
Reputation: 491
This will also work:
if ( requestScope.get('currentDocument') != null )
Upvotes: 0
Reputation: 868
You almost had it:
if( typeof currentDocument != 'undefined' )
Upvotes: 2
Reputation: 3395
If also a null check will throw an exception I'd put this in a try-catch block and the catch block to exit with doing nothing (or maybe just logging some information, setting some scope variables to present the user a message etc.)
Upvotes: 3