Problems with GlideFilter.checkRecord

AB6
Tera Contributor

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

1 ACCEPTED SOLUTION

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);

View solution in original post

11 REPLIES 11

VigneshMC
Mega Sage

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);
}

AB6
Tera Contributor

Hi

Vignesh, thank you for your quick response


I doesnt work 😞

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

AB6
Tera Contributor

Hi Vignesh, in the background script it works, but in the after BR is  not working :0