Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2018 12:43 PM
Sorry, I misunderstood your question at the first reading. What you can do is to modify the code of filterGroupsonUser to support the second parameter - the group type, which you want to filter (for example "assignment"). The code of the modified version of filterGroupsonUser could be
//Usage javascript:new BackfillAssignmentGroup().filterGroupsonUser(current.assigned_to, "assignment");
var BackfillAssignmentGroup = Class.create();
BackfillAssignmentGroup.prototype = {
initialize: function() {
},
// Filter out groups that are not the provided type
filterGroupsonUser: function (userSysId, groupTypeName) {
//return everything if the assigned_to value is empty
if (!userSysId) {
return;
}
//sys_user_grmember has the user to group relationship
var grp = new GlideRecord("sys_user_grmember");
grp.addQuery("user", userSysId);
if (groupTypeName) {
var groupType = new GlideRecord("sys_user_group_type");
if (groupType.get("name", groupTypeName)) {
grp.addQuery("group.type", "CONTAINS", groupType.getUniqueValue());
}
}
grp.query();
var groups = [];
while (grp.next()) {
groups.push(grp.group);
}
return "sys_idIN" + groups.join();
// return Groups where assigned to is in those groups we use IN for lists
},
type: "BackfillAssignmentGroup"
}
and the usage like
javascript:new BackfillAssignmentGroup().filterGroupsonUser(current.assigned_to, "assignment");