- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2016 01:19 PM
On our incident form the Assignment Group field is mandatory. Once a group is entered their, only the members of that group can be selected in the Assigned to field. I would like to do this in the reverse, initially leaving the Assignment Group empty, adding a user in the Assigned To field and then under the magnifying glass for the Assignment Group field I would only see the group or groups that user is a member of. Any thoughts are appreciated.
Thanks,
Bill Cravey
HonorHealth
william.cravey@honorhealth.com
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2016 02:01 PM
We are currently doing this, and it works fantastically!
Here is how we make it work (we also use the same logic on other fields. We have a set of 4 hierarchical fields where each one is limited by the field/s directly adjacent to it).
On Assigned to:
Dependent on = assignment_group
On Assignment group:
Ref qualifier is set to: javascript:BackfillAssignmentGroup()
Script for BackfillAssignmentGroup():
function BackfillAssignmentGroup(){
var groupList = ' ';
var assignedTo = current.assigned_to;
//return all groups if the assigned_to value is empty.
if(assignedTo == ''){
//list of groups that have the "assignment group" type, and filter out inactive groups.
return 'typeLIKE188225e715480200abe63ac4a19e9dfa^active=true';
}
//sys_user_grmember has the user to group relationship
var grpGR = new GlideRecord('sys_user_grmember');
grpGR.addQuery('user',assignedTo);
grpGR.addEncodedQuery('group.typeLIKE188225e715480200abe63ac4a19e9dfa^group.active=true');
grpGR.query();
while(grpGR.next()) {
if (groupList.length > 0) {
//build a comma separated string of groups if there is more than one
groupList += (',' + grpGR.group);
}
else {
groupList = grpGR.group;
}
}
// return Groups where assigned to is in those groups we use IN for lists
return 'sys_idIN' + groupList;
}
Please let me know if you have questions!
~Lindsey

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2017 04:58 PM
Lindsey,
I have a query running as a background script that is returning the groups that a specific user is a member of.
var kn = new GlideRecord('sys_user_grmember');
kn.addQuery('user', '797d14341f1310005a3637b8ec8b7010');
kn.addEncodedQuery('group.active=true');
kn.query();
groupList = ' ';
while(kn.next()){
gs.log('Found one = ' + kn.group.getDisplayValue());
}
Returns:
[0:00:00.006] Script completed in scope global: script
*** Script: Found one = ACME GROUP 1
*** Script: Found one = ACME GROUP
However,
When I plug the query into the Script Include, generate a new Incident record, populate the
'assigned_to' field and click the search for 'assignment_group' it doesnt filter. I see the entire
tree picker with every group available. Am I missing something?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2024 05:16 AM
This is still working in 2024 🙂 Awesome work lindsey!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2016 02:54 AM
hey : Lindsey Armstrong
Can u explain how to do this
(you have written in your previous reply)
"On Assignment group:
Ref qualifier is set to: javascript:BackfillAssignmentGroup()"
where can i find that and how.
I cannot find any javascript:BackfillAssignmentGroup() from Reference qaulifier.
Can you please explain me . I am totally new to SN.
and please also explain where to write script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2016 06:22 AM
Hi Allu,
Reference Qualifier fields are text, so it wont' have a lookup on it. The reference qualifier field is on the dictionary entry for the assignment group field itself (or any other field, for that matter).
The ref qual is looking for a script called BackfillAssignmentGroup().
Before it will work, you'll need to create a script include that contains the script above, but will need to modify the script slightly depending on your environment. We use group types, so we are filtering on that. If you do not use group types, you'll need to adjust the query. Even if you DO use group types, you'll need to put in your own sys_id for the group type you want to see.
It certainly takes awhile to get used to everything in the system! I hope that helps and good luck!
~Lindsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2016 02:49 AM
Dear Lindsey
Can you explain me more clearly because I am not getting it
I have copied above code exactly and it is not working.
Please help me out.