Remove Roles From a Group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2022 04:08 AM
HI,
How can we remove role from a group using script?
Is there any way we can delete any role from a group based on user input?
Regards,
Surbhi
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2022 04:12 AM
Hi Surbhi,
Please try below code.
var role = new GlideRecord('sys_group_has_role');
role.addQuery('group', current.sys_id);
role.addQuery('role', '<ROLE_SYS_ID>');
role.query();
while(role.next())
{
role.deleteRecord();
}
Regards,
Chaitanya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2022 04:22 AM
Hi,
Yes, we can do that, you can use script logic suggested by Chaitanya.
Can you please share what exactly you want to achieve? Also check the possibilities using no code (FLOW) configurations.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2022 04:31 AM
Hi Anil,
Above Script which is suggested by Chaitanya is not working out for me, My requirement is suppose we have a group--SRM Support which have 5 different roles and based on end user one of the role should be removed.
# I cant use No code here, i need script to execute
How can we delete it using script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2022 04:37 AM
Are you trying through background script or fix script