- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2017 11:08 AM
Hi all. A customer has requested this.. On their self service form they want their users to be able to assign their own record to a team and an individual. To do this I need to recreate the relationship between Assignment group and Assigned to as it is on the Task table. From asking a similar question previously, I understand this isn't simple. However, I have come across a piece of code that I think might work with some tweaking - unfortunately I haven't been able to do it this myself.
I have created two variables on the Record Producer (assignment_group and assigned_to). They are Lookup Select Boxes that reference their respective tables. The requirement is for the user to select the team they wish to assigned their request to, then select the team member. I need the script to only show the members of the selected group, as it would on the Task table. This is the script I was referring to which I've put in the Reference qual field on the variable:
javascript:var grp = g_form.getReference('assignment_group');var gr = new GlideRecord('sys_user_grmember');gr.addQuery('group',grp);gr.query();var users='';while(gr.next()){users+=gr.user.sys_id + ",";}"sys_idIN" + users;
I use the above script on a task record where I want to limit the users shown in a reference field based on a group, usually specified by its sys_id. Here is how the script looked before I updated it:
javascript:var gr = new GlideRecord('sys_user_grmember');gr.addQuery('group',"5ed4e1fbdb08a2001d8cbd9eaf9619a3");gr.query();var users='';while(gr.next()){users+=gr.user.sys_id + ",";}"sys_idIN" + users;
This is the rest of the variable details on the RP:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2017 11:22 AM
Change the field to be a Reference field and use the following script as a reference qualifier:
javascript: group_members();
function group_members(){
var answer = [];
var group = current.variables.assignment_group
var group_members = new GlideRecord('sys_user_grmember');
group_members.addQuery('group',group);
group_members.query();
while(group_members.next()){
answer.push(group_members.user.sys_id + '');
}
return 'sys_idIN' + answer.join(',');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2017 11:21 AM
This post will help you
Reverse the dependency between user and assignment group for Incident
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2017 11:22 AM
Change the field to be a Reference field and use the following script as a reference qualifier:
javascript: group_members();
function group_members(){
var answer = [];
var group = current.variables.assignment_group
var group_members = new GlideRecord('sys_user_grmember');
group_members.addQuery('group',group);
group_members.query();
while(group_members.next()){
answer.push(group_members.user.sys_id + '');
}
return 'sys_idIN' + answer.join(',');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2017 12:58 AM
Thanks Ulrich. It's a shame this doesn't work with a Lookup Select Box.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2021 02:48 AM
I've been trying for hours to get this working - so many different answers about! This one worked an absolute treat. Thank you so much.