How to query out fields that have an empty value with GlideRecord?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2019 06:47 AM
I tried this and it didn't work
current.addQuery('location', '!=', "");
current.addQuery('cmdb_ci', '!=', "");

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2019 08:02 AM
Just tested with below code on Incident related list. No issues 😞 Only records with cmdb_ci are shown.
(function executeRule(current, previous /*null when async*/) {
// current.addQuery('cmdb_ci', '!=', '');
current.addNotNullQuery('cmdb_ci');
})(current, previous);
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2019 06:57 AM
Hey Mitch,
I believe using an encoded query will work for this.
Something like the below for example:
current.addEncodedQuery('locationISEMPTY^cmdb_ciISEMPTY');
If my reply helps you at all, I'd really appreciate it if you click the Helpful button and if my reply is the answer you were looking for, it would be awesome if you could click the Accepted Solution button! 🙂
I hope this helps, have a great day!
Steve

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2019 07:00 AM
Ah that's a nice thought too!
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2019 07:50 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2019 05:53 AM
This is so weird. So without trying anything you guys suggested I get this: 23 incidents
And this for another incident: 9 incidents
Now when I add current.addQuery('cmdb_ci', '!=', "NULL"); or current.addNotNullQuery('cmdb_ci'); It gets rid of the empties in one incident, but not the other one??
21 incidents now:
9 incidents still:
Maybe this one incident is bugged?