- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on ‎06-11-2020 10:09 PM
GlideElement - nill()
Determines if the field is null, applicable only to the elements of glideRecord object.
Returns true if the field is null or an empty string, false
The downside is, this method can not apply to native javascript variables.
var glideRecord = new GlideRecord('incident');
glideRecord.query('priority', '1');
glideRecord.next();
gs.info(glideRecord.state.nil());
GlideSystem - nil(Object to)
Queries an object and returns true if the object is null, undefined, or contains an empty string.
Returns, True if the object is null, undefined, or contains an empty string; otherwise, returns false.
This method can be used on native javascript objects, for example, if you're passing an object to a function as a parameter, you would like to ensure the object is not empty and not null, you could use this method.
var gr = new GlideRecord();
gs.info(gs.nil(gr));
JSUtil – nil(object item)
Checks if an item is null, undefined, or evaluates to the empty string.
Returns True if the item is null, undefined, or evaluates to the empty string.
var x = "the quick brown fix";
var y = "";
var z ;
gs.print("x = '" + x + "', JSUtil.nil(x) = " + JSUtil.nil(x));
gs.print("y = '" + y + "', JSUtil.nil(y) = " + JSUtil.nil(y));
gs.print("z = '" + z + "', JSUtil.nil(z) = " + JSUtil.nil(z));
all of these checks can be handled by using the if statement and a logical NOT operator such as if(!x).
Thanks
Venkat
- 33,536 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Very helpful.. Explained clearly..
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Awesome explanation!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
superb
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Very Helpful

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
is there a similar neat equivalent for client script to avoid long if
condition?