- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2018 01:14 AM
Hi community!
I am trying to use GlideFilter.checkRecord method but it doesnt work
Here is my code:
var group = new GlideRecord('u_custom_ag');
group.query();
//var bool = true;
var bool = GlideFilter.checkRecord(current, group.u_condition);
while(group.next())
{
if (bool == true) {
gs.info('success');
current.assigned_to = group.u_assigned_to;
current.assignment_group = group.u_assignment_group;
current.u_string = 'SUCCESS';
}
}
Any idea why is not working
Regards
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2018 03:25 AM
syntax of checkRecord is
checkRecord(GlideRecord gr, String filter, Object matchAll)
in your script in place of "string filter" you have group.u_condition, i am not sure if thats correct. I am assuming your group.u_condition has string filter . if above assumptions are true then
try
(function executeRule(current, previous /*null when async*/) {
var group = new GlideRecord('u_current_ag');
group.query();
var bool = true;
while(group.next())
{
bool = GlideFilter.checkRecord(current, group.u_condition);
if (bool) {
gs.info('success');
current.assigned_to = group.u_assigned_to;
current.assignment_group = group.u_assignment_group;
current.u_type = 'SUCCESS';
current.update();
}
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2018 01:27 AM
try adding it after the while loop
eg:
var rec = new GlideRecord('incident');
rec.query();
var bool = true;
while(rec.next())
{
bool = GlideFilter.checkRecord(rec, "active=true");
gs.info("number "+ rec. number + " is " + bool);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2018 01:36 AM
Hi
I doesnt work 😞

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2018 01:41 AM
if its an after update BR, you have to add current.update().
Try to debug by running this against a single record in background script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2018 03:02 AM
Hi Vignesh, in the background script it works, but in the after BR is not working :0