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
02-07-2018 08:16 AM
this seems to always pass assigned_to as a blank value so never actually filters the assigned_group field?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2018 09:03 AM
Try this Script Include - Someone shared it with us, only thing I don't like about it is once you select the Group the user is in you will have to find the User again to update the Assigned to field because it removed it.
Mark
// var getAssignedToGroups = Class.create();
// getAssignedToGroups.prototype = Object.extendsObject(AbstractAjaxProcessor, {
// type: 'getAssignedToGroups'
// });
function getAssignedToGroups() {
var assignToGrpList = [];
var assignedTo = current.assigned_to;
// section for case where assigned to is empty
if (!assignedTo) {
gs.log("ggggg");
var grp77 = new GlideRecord("sys_user_group");
grp77.addQuery("assignment_group", 'true');
grp77.query();
while(grp77.next()) {
assignToGrpList = assignToGrpList + "," + grp77.sys_id;
}
assignToGrpList = assignToGrpList.toString();
//return "sys_idIN" + assignToGrpList;
return "sys_idIN" + assignToGrpList;
}
// section for case where assigned to is not empty
gs.log("sssssssss");
var grp = new GlideRecord("sys_user_grmember");
grp.addQuery("user", assignedTo);
grp.query();
while(grp.next()) {
gs.log(grp.group.name);
var grpsysid = grp.group.sys_id;
gs.log(grpsysid);
var grp88 = new GlideRecord("sys_user_group");
grp88.addQuery("sys_id", grpsysid);
grp88.addQuery("assignment_group", 'true');
grp88.query();
while(grp88.next()) {
gs.log("jjjjjjj");
var pare = grp88.parent;
var paresysid = grp88.parent.sys_id;
gs.log(pare);
gs.log(paresysid);
gs.log(grp88.parent.name);
assignToGrpList = assignToGrpList + "," + grp88.sys_id + "," + paresysid;
gs.log(assignToGrpList);
}
}
assignToGrpList = assignToGrpList.toString();
return "sys_idIN" + assignToGrpList;
}