Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Filter out people which are on leave

SnowUserDev
Tera Contributor

Hi Experts,

 

I need help in one logic where in a variable I am getting multiple people. Now what I want to do is I want to remove people who will be absent(their data is present in one table) from that available variable.

How can this be achieved?

1 ACCEPTED SOLUTION

Hi @SnowUserDev ,

 

Try the below code n see if it works or not

var finalusers = '';

var a = user1,user2,user3;

a = a.split(',');

for(var i=0;i<a.length;i++){

var gr = new GlideRecord ('table_name');

gr.addQuery('user_field_name',a[i]);

gr.addQuery('active',true);

gr.query();

if(gr.next()){

//do nothing

}else{

finalusers.push(a[i]);

}

}

gs.info(finalusers);

 

Thanks,

Danish

 

View solution in original post

5 REPLIES 5

@Danish Bhairag2  perfect it worked