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
‎11-30-2017 11:27 AM
Your can create on change client script to populate group text field field group id seprated by comma.
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 06:30 PM
On which table I need to write client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 12:07 PM
Use below onChange client script on agent field.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var groups = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user',newValue);
gr.query();
while(gr.next())
{
groups.push(gr.group);
}
g_form.setValue('u_groups',groups);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 06:28 PM
On which table we have to write this script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 12:18 PM
gtk wrote:
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
... erm.. this feels like duplicating existing functionality. Why create a separate table with similar information then try to relate/sync them?
It sounds like what you're after is a reference qualifier to limit down enumerated picklists.