Try Catch Throw in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 11:23 PM
So I've setup a code in a try-catch statement where it throws the code if it passes the given if-statement:
if(requestEntry.cmdb_ci == null) throw "CI is missing";
Seems correct right? But when I've executed the test on the code, a certain error came out:
"Cannot convert CI is missing to com.glide.rest.service.custom.errors.ScriptableServiceError (sys_ws_operation.a001d9284fd5ba0022493faf0310c7da.operation_script; line 110)"
Seems that the given class is not allowing me to throw the error message that I've created. Do you have any suggestions on how to work around this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 11:35 PM
Try requestEntry.cmdb_ci === null.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2017 05:58 PM
What I'm trying to look for is the function of the Throw statement in ServiceNow, not the operator. The suggestion you provided is simply an operator which is for a strict comparison.