The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
SlightlyLoony
Tera Contributor

find_real_file.pngDid you know that your Service-now instance comes complete with a handy-dandy set of commonly used JavaScript utility methods? These are in a script include named "JSUtil", and you can easily use its methods in your scripts.

For example, there's a method named "nil()" (along with "notNil()" that lets you easily test whether a value is null, undefined, or an empty string. You might use it in your own code it like this:


function myFunc(val) {
if (JSUtil.nil(val))
return null;
return 'My prefix: ' + val;
}

That's all there is to it! Take a look at the script include to see what's in it — all the methods are documented. And if you think of another method that ought to be in there, please add a comment describing what you'd like to see...