Filter Assignment Group based on Assigned To
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2017 09:03 AM
Occasionally we will assign an Incident, Problem, Change to the Assigned To prior to choosing an Assignment Group. Once the Assigned To is populated I would like to filter the Assignment Group list to include only Groups that the Assigned To is a member of. Can anyone help me with the code for such a request?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2017 09:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2017 10:27 AM
Hi Eric,
You can obtain the groups depending on the user or in this case depending on the assigned to user
var assignedUsr= gs.getUser();
assignedUsr= assignedUsr. getUserByID( sys_id);
assignedUsr.getMyGroups()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2017 12:41 PM
I followed the link posted above with failing results. There are two articles, one says to add the code to a script include, the other link says to add it to a business rule. I've tried both. Neither is working for me. Can anyone break it down into high level steps I need to follow. I'm not a trained java scripter so I'm just copying scripts, I don't actually know what they do.
Thanks again for all the help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2017 09:00 AM
The following should work for what you need. Build out the following script include and add the reference in the reference qualifier in the assignment group field.
Script include: filterAssignmentGroups
// ------------------------------------------------- // Reference: Group // Use Reference Qualifier: Advanced // Reference qual: javascript:filterAssignmentGroups(current.sys_class_name, current.assigned_to); // -------------------------------------------------- function filterAssignmentGroups(table,assignee){ var string = "sys_idIN"; if(assignee == ""){ var gr = new GlideRecord("sys_user_group"); gr.addQuery("active",true); gr.query(); while(gr.next()){ string += gr.sys_id + ","; }
} else { var grmem = new GlideRecord("sys_user_grmember"); grmem.addQuery("user", assignee); grmem.query(); while(grmem.next()){ var grLook = new GlideRecord("sys_user_group"); grLook.addQuery("sys_id",grmem.group); grLook.addQuery("active",true); grLook.query(); while(grLook.next()){ string += grLook.sys_id + ","; } } } return string; } |
High Level:
1. Create Script Include.
2. Paste Above Script in the include.
3. Right click on the assignment group field.
4. Set fields as follows: