- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2014 01:33 AM
I'm trying to wrap my head around using the condition builder, and would appreciate any help you could give.
Specifically i want to know how ServiceNow checks the condition specified on a record is a match to the current record
For example: How does ServiceNow check the Client template conditions match the current incident field values?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2014 08:19 AM
Hi Neil,
The first thing to understand about the Condition Builder is that it stores its result as an Encoded Query. This is the same Encoded Query format used in the URL sysparm_query parameter, reference qualifiers, and List filters. This can give you an indication of some ways on how to make use of it. For instance, in the following examples I will assume a custom u_condition field is the condition builder and condGR is a GlideRecord containing the field:
Check for a Record Match Using GlideRecord
The advantage of this approach is it uses documented code only
var gr = new GlideRecord('incident'); // Lets check to see if an incident matches the condition
gr.addEncodedQuery(condGR.u_condition);
gr.addQuery('sys_id', 'Inicdent Sys ID here');
gr.setLimit(1); // We only need to know if the one Record Matches
gr.query();
if (gr.next()) {
// Record matches the condition
}
Check for a Record Match Using GlideFilter
This method uses an undocumented Glide API that you can find in a few places in OOB scripts. GlideFilter accepts two parameters. The first is the GlideRecord object to check against a condition. The second is the condition string itself. This function returns true or false depending on whether the record matches or not.
var gr = new GlideRecord('incident');
gr.get('Incident Sys ID here');
if (GlideFilter.checkRecord(gr, condGr.u_condition)) {
// Record matches the condition
}
I hope this has helped. Please let me know if you need more information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016 08:50 AM
Hi Travis - I just posted a blog article GlideFilter and Regular Expression Match summarizing all I know about GlideFilter, and also referenced your post. Any feedback would be great. Thanks.
Please feel free to connect, follow, mark helpful / answer, like, endorse.
John Chun, PhD PMP ![]() | ![]() |

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2020 11:10 PM
This is super cool. I was struggling where addEncodedQuery was not working in all cases. GlideFilter.checkRecord() seems to be working in all cases. I am testing out all scenario. Thanks for the solution!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2014 05:25 AM
This video from TechNow was a huge help for me in understanding the use of Conditions fields:
I'm finding more and more uses for Condition fields.
Michael