- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 11:31 AM
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?
Solved! Go to Solution.
- Labels:
-
Architect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 11:12 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 06:16 PM
Hi @SnowUserDev,
Please share more technical details about the variable.
If variable is reference to sys_user table and user's absent ( or leave ) data available in any custom table then you can achieve the desire result in following way.
1) create view on user & custom table and user this view in variable.
2) write script include code, to filter the absent users data and get the available user's list
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 06:28 PM
Hi @SnowUserDev ,
Could u elaborate a bit more, when u say data is available in the table wht kind of data is available?
Also in the variable when values for people are stored how is it stored?
Comma seperated or in any other way.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 10:58 PM
Hi @Danish Bhairag2 @AshishKM ,
So the variable contains values from a list collector variable let's say variable
var a = user1,user2,user3
In one table I have info related to above user whether they are on leave or not.
If value is present on that table and active then I need to remove that user from "a" variable. In the table the user field is reference field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 11:12 PM
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