Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Reference Qualifier not working

venkatsaladi
Tera Contributor

Hello Community, I had writing a advanced reference qualifier for the assigned_to field on the incident table such that whenever the user selects a specific assignment_group, assigned_to field should only list active users for that I wrote a advanced script , below is my code, upon testing it is not working as expected. Your inputs are highly appreciated thanks.

image.pngimage.png

1 REPLY 1

Satyapriya
Mega Sage

Hello @venkatsaladi ,
You are calling the wrong function in the reference qualifier.
Please use the correct function in the reference qualifier like this:
javascript: new terminator().getActiveUsers(current.assignment_group);

Please try  using  this code in the script include and make sure the script include is set as client callable.

var terminator = Class.create();
terminator.prototype = {
initialize: function () {},

// Make sure to check "Client Callable"
getActiveUsers: function (groupID) {
var inactiveID = [];
if (groupID) {
var grp = new GlideRecord("sys_user_grmember");
grp.addQuery("group", groupID);
grp.query();
while (grp.next()) {
// pick sys_id of user who is active
if (grp.user.active == true) {
inactiveID.push(grp.user.toString()); // sys_id
}
}
}
return 'sys_idIN' + inactiveID.join(",");
},

type: 'terminator'
};