FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



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...
 
EDIT:
- 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.
 
Thanks!!...

FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.