Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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...