Jul 11, 2011, 1:13 PM
64 Posts
topic has been resolvedResolved

if(currentDocument!=null) causes SSJS to crash

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.1
  • Role: Developer
  • Tags: currentDocument SSJS crash
  • Replies: 2
- I have a custom control that needs to check if currentDocument exists, and if it does not then bypass some code.  But the check itself causes the SSJS to fail catastrophically with an ugly stack trace page, complaining that currentDocument doesn't exist.  How does one check if currentDocument exists without crashing the application?
Thanks for your time...
- Testing against various combinations of undefined doesn't work, either (!=, ==, ===).  Any attempt to refer to currentDocument crashes instantly, even an if(...) { }.
Jul 11, 2011, 2:01 PM
129 Posts
Re: if(currentDocument!=null) causes SSJS to crash
Try using:
if( typeof currentDocument === 'undefined' )
Jul 11, 2011, 5:48 PM
64 Posts
Re: Dang, missed the quotes initially...
- You are absolutely correct.