get list of groups user belongs to
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 11:17 AM
we have created a new custom table with name u_work_group
in which it is having list of 50+ groups, and now we got a requirement that
create a field which refers to sys_user table
and when user is selected then ln a text box to be shown with list of groups that user is member of
agent - type is reference - points to sys_user
groups - type is text box - get group of user
(groups to be separated with comma [,])
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2017 06:26 AM
can you suggest how to relate/sync groups to table,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2017 06:42 AM
When you say "create a field which refers to sys_user table" , it sounds like you want to use a use a reference field.
If you go to the user record, you can see what groups they belong to there. I may be misunderstanding what you're doing here, but it sounds like effort duplication.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2017 06:54 AM
looks good,
but here our requirement is to create a separate table is to get groups from AD and group members i.e., we should not add/remove groups/group members but it has to sync from AD to SNOW and maintain table to be like an sys_user_group [replicate] in table.
and to create a service request with fields User and Groups : if any user is ls selected then in groups field it has to populate the groups [AD]user belongs to

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2017 07:39 AM
1. Create a client script and pass the user sysid.
2. Create a Script Include and get the user sysid parameter and write the below code to fetch the groups:
var usersysid = this.getParameter("sysparm_usersysID");// fetch sysid here
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("user",usersysid);
gr.query();
while(gr.next())
{
gs.print("User is in group::"+gr.group.getDisplayValue());
}
3. collate the groups here and return.
4. In the client script set the values by g_form.setValue.
NOTE : If using a BR simply use GlideRecord code and set it via :
gr.work_notes = Value;
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2020 12:00 AM
it's not working