
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2016 09:51 AM
This may be an odd question. I have a table where I can define "rules" using a condition field to drive if the rule is applied. This works great when I can query for the records I want to apply the rule to:
var grRules = new GlideRecord('rules');
grRules.addQuery('type', 'incident');
grRules.query();
if (grRules.next()) {
var grIncident = new GlideRecord('incident');
grIncident.addEncodedQuery(grRules.condition);
grIncident.query();
while (grIncident.next()) {
//apply rule
}
}
In this example there is a table that defines rules based on condition. It pulls all existing records for that condition and applies the rule.
What if I want to apply the rule to a record that has not been created yet:
var grIncident = new GlideRecord('incident');
grIncident.initialize();
grIncident.field1 = value1;
grIncident.field2 = value2;
...
var grRules = new GlideRecord('rules');
grRules.addQuery('type', 'incident');
grRules.query();
if (grRules.next()) {
// IF grIncident meets the grRule.condition
{
//apply rule
}
}
grIncident.insert();
Here I want to see if my new record meets the conditions defined in my rule table. Is there a way to check an encoded query string against a single record?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2016 09:53 AM
Hi Aaron,
You're looking for GlideFilter.
Have I got a video for you...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2016 09:53 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2016 11:14 AM
Thanks, that is exactly what I'm looking for.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2016 11:14 AM
One of my favorite tools!