- 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
‎09-26-2016 07:47 AM
The main piece of the code you need to modify is:
//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';
}
If you do not use group types, then it should read:
return 'active=true';
If you do use group types, you'll need to replace the sys_id with the appropriate one from your environment.
There may be other factors in your environment that will cause this to not work. In that case, I'm not sure I can be of more assistance without being in your environment.