- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2018 09:02 AM
I need to pull from a Change_Approver group that contains all managers, and a Change_Approver_Delegates group that I must limit to the delegated approvers for the same department as the assigned_to in the current change request.
I'm using a script include to pull the members of the Change Approver group put I need to pull from two assignment groups and put the additional restriction of the same department on the delegates group.
Here is a sample of what i have but I am having trouble getting the script include to pule from two groups
javascript: new ACMEUserGroupUtils().getGroupMembers(gs.getProperty('change.approval.groups'), current.assigned_to) + "^department=" +current.assigned_to.department
script include below
var ACMEUserGroupUtils = Class.create();
ACMEUserGroupUtils.prototype = {
initialize: function() {
},
/*
getGroupMembers() function returns the list of the group members of the
groupName passed as a parameter.
*/
getGroupMembers: function(groupName, excludeUsers) {
var answer = [];
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery('group.name', groupName);
grMember.query();
if (excludeUsers != '') {
while (grMember.next()) {
if (excludeUsers.indexOf(grMember.user.toString()) == -1) {
answer.push(grMember.user.toString());
}
}
}
return 'sys_idIN' + answer.toString();
},
/*
isUserInGroup(): returns the user only if the user is a member of the group, empty otherwise.
Note: does not return boolean as function name would suggest.
*/
isUserInGroup: function(user, group) {
//returns user if they are a mmember of the group.
var answer = '';
if (gs.getUser().getUserByID(user).isMemberOf(group)) {
answer = user;
}
return answer;
},
type: 'ACMEUserGroupUtils'
};
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2018 02:47 PM
Use this
javascript: new ACMEUserGroupUtils().getGroupMembers('Change_Approvers', current.requested_by) +'^OR'+ new ACMEUserGroupUtils().getGroupMembers('Change_Approver_Delegates', current.requested_by) + "^department=" + current.assigned_to.department
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2018 01:31 PM
Can you help me again?
I am now writing a reference qualifier to restrict the selection of the Assigned_to on a Change Task
the following code is working
javascript: "sys_id!=" + current.change_request.u_approver + "^sys_id!=" + current.change_request.requested_by + "^sys_id!=" +current.change_request.assigned_to
I don"t know how to write one more query for this reference qualifier. We created a new field on the Change Task called Change Task type or u_change_task_type . Its a string and we have the value of Test in this field so we can Identify which Change Tasks are test tasks.
I am trying to limit the execution of the query above to only the change tasks that have the value of "Test" in the u_change_task_type field on the Change Task form.
I tried this and it didn't work
javascript: “current.u_change_task_type=” + ‘Test’ + "sys_id!=" + current.change_request.u_approver + "^sys_id!=" + current.change_request.requested_by + "^sys_id!=" +current.change_request.assigned_to
Please any help is appreciated
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2018 01:37 PM
Here you go
javascript: “u_change_task_type=Test’ + "^sys_id!=" + current.change_request.u_approver + "^sys_id!=" + current.change_request.requested_by + "^sys_id!=" +current.change_request.assigned_to
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2018 01:59 PM
Unfortunately, that didn't work
I tried adding current in fromt of U_change_task_type like this...
javascript: “current.u_change_task_type=Test’ + "^sys_id!=" + current.change_request.u_approver + "^sys_id!=" + current.change_request.requested_by + "^sys_id!=" +current.change_request.assigned_to
but that didnt work either. also tried double quotes after Test...no luck
the reference list is still showing the approver, assigned_to and requested_by in the parent change request

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2018 02:34 PM
You need to create a script include for this. And put the following code in there and call the script include in the ref qual section
if(current.u_change_task_type=='Test’){
return "sys_id!=" + current.change_request.u_approver + "^sys_id!=" + current.change_request.requested_by + "^sys_id!=" +current.change_request.assigned_to;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2018 03:14 PM
Thanks...
That's what I was thinking....I'll give it a shot!