- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2023 09:12 PM
Hi Experts
i have a list of employee id attributes which are in the sys_user table
e.g. employee number 24424,4423,63346,52525,252552 etc
i need to add these users to the group.
i could write a encoded query but since list of enployee number is huge, if there is way to do it via a fix script or background script
Thanks
Levino
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2023 09:38 PM - edited 07-19-2023 09:39 PM
Hi @levino ,
Do you have a array of empIDs ready?
You can use this!
var empID = [<emp I'd of all empyin string>];
var gr= new GlideRecord('sys_user');
gr.addEncodedQuery('emp_idIN'+empID.toString());
while(gr.next()){
var grmem = new GlideRecord('sys_user_grmember');
grmem.initialize();
grmem.group = 'sys id of group';
grmem.user = gr.sys_id;
grmem.insert();
}
If you are looking for something else, please let me know.
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2023 09:16 PM
Hi @levino
In that case make use of Transform map.
Hope it helps and please mark helpful if it solves the issue.
Thanks,
Pooja Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2023 09:38 PM - edited 07-19-2023 09:39 PM
Hi @levino ,
Do you have a array of empIDs ready?
You can use this!
var empID = [<emp I'd of all empyin string>];
var gr= new GlideRecord('sys_user');
gr.addEncodedQuery('emp_idIN'+empID.toString());
while(gr.next()){
var grmem = new GlideRecord('sys_user_grmember');
grmem.initialize();
grmem.group = 'sys id of group';
grmem.user = gr.sys_id;
grmem.insert();
}
If you are looking for something else, please let me know.
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 04:18 PM
Hi Rahul
var empID = '882332,32253,235523';
is this the format?
encoded query should it be 'employee_numberIN
Thanks
Levino
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 09:34 PM
Hi @levino ,
If you use
var empID = '882332,32253,235523';
with this you can directly use -
'employee_numberIN'+empID;
and, If you use -
var empID = ['882332','32253','235523'];
than you have to use
'employee_numberIN'+empID.toString();
Thanks and Regards,
Rahul
