Tag a role to an Assignment Group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 10:15 PM
Folks,
Need your help on how to add/append a Role to an Assignment group via script.
On a custom module, user will select a Role (Choice) and Group (Reference), once saved I want to add that role into the group, so that everyone under that Group will inherit the Role.
Kindly suggest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2024 07:41 AM
Hi @sachinhs
Why don't you use the Flow designer and catalogue item for the same? Create a catalogue item ask the user about role and group and then in flow in action update the record.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 01:41 AM
Have to agree with @Dr Atul G- LNG here. A lot less can go wrong if you use Flow Designer.
Assuming the user is filling out a form on the Catalog....
Trigger: Catalog Item
Flow
1 - Get Variables
2 - Lookup record (sys_group_has_role) where...
- role is same as role variable
- group is same as group variable
3 - If 2 returns something
4 notify user group already has that role
5 ELSE
6 Create Record (sys_group_has_role)
--- role = role variable
--- group = group variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2024 08:44 AM
Hi @sachinhs ,
You can create after insert business rule on custom table with below script.
var role = new GlideRecord('sys_group_has_role');
role.initialize();
role.group = current.groupfiled_backendname;
role.role = current.rolefiled_backendname;
role.insert();
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2024 04:24 AM
Thank you Anand for the response.
If i can seek some more help, below is my form from a custom application.
Here Role is "Choice" and Assignment Group is "Reference". To retrieve a Choice field's value from BusinessRule, should we use Client script and AJAX & then trigger BusinessRule?
Kindly suggest..