Adding User in a group via related list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 01:39 AM
Hello All,
We have a table called "u_site_function" which is having a related list called "Leads".
When we select any user in the Leads related list then the user should be automatically added to a specific group called "SITE LEADS".
Can someone please help how to achieve this?
Thanks,
Sattar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 01:47 AM
Check on the 'leads' record. Are you creating a real record on a custom table, or is it a relationship table?
On change of that table (either one of the two), trigger a flow and create a sys_user_grmember record whit the group as group and the user as the user triggered on the created record.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 04:44 AM
Hi @sattar3 ,
To add users to a group via the related list , follow below steps:
- navigate to system defination > relation ships . create a relationship & add it to the table (configure->related list ) .
- create a ui action (list choice), to add selected users to the specific group (i.e whenever you select specific users from the related list then perform action on that selected rows -> by clicking on that ui action . add the below code in ui action :
var gr = new GlideRecord('sys_user_grmember');
gr.initialize();
gr.user = current.sys_id;
gr.group = '3457309847bf421096e4224f316d43b8';
gr.insert();
gs.addInfoMessage('User has been successfully added to the group.');
whenever user selects the specific users from the related list and clicks on that ui action then they will be added to that specific group.
if my solution is helpful , please mark it as helpful .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 05:00 AM
you didn't share some more details, screenshots etc
How is that Leads table related to Site function table?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader