- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 12:42 AM
1. I have created one catalog item "Add Remove client portal Admnistrators".
2.On this catalog item added two variables:
1.Contact to Add - When the User move in Selected, Automatically add to the 'Client portal group'
2.Contact to Remove - When User move in Available,Automatically remove from the 'Client portal group'.
3.My requirement is adding or removing users from the 'Client portal group'. I want to implement this using workflow.
Thank You.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 03:35 AM
Hi,
try this
var usersToAdd = current.variables.contact_to_add.toString().split(','); // give correct variable name here
var usersToRemove = current.variables.contact_to_remove.toString(); // give correct variable name here
var rec = new GlideRecord('sys_user_grmember');
rec.addQuery("group.name", "Client portal group");
rec.addQuery("user", 'IN', usersToRemove);
rec.query();
while(rec.next())
rec.deleteRecord();
for(var i in usersToAdd){
var rec1 = new GlideRecord('sys_user_grmember');
rec1.addQuery("user", usersToAdd[i]);
rec1.addQuery("group.name", "Client portal group");
rec1.query();
if(!rec1.hasNext()){
rec1.initialize();
rec1.user = usersToAdd[i];
rec1.setDisplayValue('group', "Client portal group");
rec1.insert();
}
}
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 06:10 AM
Hi Ankur,
Thanks for response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 06:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 06:16 AM
Can you post a new question for this and share the script and tag me there as this is an old thread?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 05:54 AM
Hi Ankur
I am trying to delete the group members and set the group values empty with below workflow run script
but not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 06:06 AM
Can you post a new question for this and share the script and tag me there as this is an old thread?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader