- 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:39 PM
Hi @levino ,
var gr = new GlideRecord('sys_user_grmember');
gr.initialize();
gr.group=current.variables.variable_name_group;//field name or the object where group sys_id is stored on the form
gr.user = current.variables.variable_name_user;//field name or the object where user sys_id is stored on the form.
gr.insert();
