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 06:52 AM
Hi there,
You are mentioning GlideRecord but I see current? Or is this for a query Business Rule for example, to limit the query, then this could be fine. Not sure, but maybe addNullQuery / addNotNullQuery will work there also?
See examples from GlideRecord below.
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:54 AM
It's a relationship for a related list. Ohh I think that'll work let me check and then get back to you

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2019 07:58 AM
Hi there,
Just tested. Technically the addQuery and multiple addQuery should work fine.
I just tested with a before Query Business Rule with below code, no issues.
(function executeRule(current, previous /*null when async*/) {
current.addQuery('urgency', 1);
current.addQuery('category', '!=', '');
current.addQuery('u_test_date', '!=', '');
current.addActiveQuery();
})(current, previous);
How is your Business Rule looking like completely?
And have you tested the different queries also separately, to see which one might not be working and causing the issue?
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