there is a problem in reference qualifier

shaafi9631
Tera Contributor
HELP!!!
writing a script include that it should only display assigned to fields which are same as to caller field location, assigned to field should only display the records which has same location as caller.
reference qualifier.jpg

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

    user: function(userid) {
        var arr = [];
        var s;
        var gr = new GlideRecord("sys_user");
        gr.addQuery("sys_id", userid);
        gr.query();
        while (gr.next()) {
            loc1 = gr.location;
            gs.info(loc1);
        }
        var grr = new GlideRecord("sys_user");
        grr.addQuery("location", loc1);
        grr.query();
        while (grr.next()) {
            s = grr.sys_id;
            arr.push(s);
            gs.info(s);
        }
        return 'sys_idIN' + arr.join(",");

    },

    type: 'getHardwareUser'
};
1 ACCEPTED SOLUTION

Hi @shaafi9631 ,

did you add it in the dictionary override?

it's for the incident table assigned to field only right?

open the dictionary override record of the assigned to field 

ChaitanyaILCR_0-1751028295109.png

and add it

ChaitanyaILCR_1-1751028300007.png

 

don't wanna keep the existing ref qual conditions?

if you want to keep the existing condition and extend this addition filter use this

else use the ref qual I share in the ref qual directly

ChaitanyaILCR_2-1751028494255.png

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

 

View solution in original post

8 REPLIES 8

Hi @shaafi9631 ,

sure update your script include as

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

    user: function(userid) {

        var userGr = new GlideRecord("sys_user");
        if (userGr.get(userid)) {
            return 'location=' + userGr.getValue('location');
        }
        return '';

    },

    type: 'getHardwareUser'
};

and ref qual as

javascript:new getHardwareUser().user(current.caller_id);

 

ChaitanyaILCR_0-1751030905805.png

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

RashmiG35965605
Tera Contributor

Script Include:

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

getUsers: function(callerId) {
var userList = [];
var callerGR = new GlideRecord('sys_user');
if (callerGR.get(callerId)) {
var callerLocation = callerGR.location;
if (callerLocation) {
var userGR = new GlideRecord('sys_user');
userGR.addQuery('location', callerLocation);
userGR.query();
while (userGR.next()) {
userList.push(userGR.getUniqueValue());
}
}
}
return userList.join(',');
},

type: 'GetUsersByCallerLocation'
};

Reference qualifier:
javascript:GetUsersByCallerLocation.getUsers(current.caller_id);

Updating reference qualifier:
javascript: new GetUsersByCallerLocation.getUsers(current.caller_id);

Ankur Bawiskar
Tera Patron
Tera Patron

@shaafi9631 

the field on which you are applying is on which table?

this should work ideally

javascript:'location=' + current.caller_id.location.sys_id;

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader