ServiceNow advance reference qualifier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 04:16 AM
My Advance reference qualifier for
"Caller field in Incident will show users of only department of logged in user" not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 05:38 AM
Hello @AakashG2703 ,
Thank you for replying
i made the script include client callable
but still it is not working.
is there any issue in my script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 05:46 AM
Hi @shivani18,
Request you to try to create a new "Script Include" as "Client Callable". Pls do not modify an existing one. There is a reason that I personally seen many times behind to not to modify an "existing Script Include" as it does not get updated as per the "Checkbox Selection or De-Selection".
If you find any information/knowledge/solution helpful, please don't forget to mark my solution and reply as helpful and accepted.
Thanks :)
Aakash Garg
ServiceNow Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 06:15 AM
hello @AakashG2703 ,
no its still not working.
may be there is some issue in my script's query
can you please check once again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 11:33 AM
Hi @shivani18,
Hope you are doing well.
Proposed Solution
I tried again to rectify your issue on my "Personal Developer Instance" so that you can get the solution as soon as possible. As a solution, I started looking into your script and implemented it on my PDI and started debugging it by adding lot of "System Logs" and here are some findings that I found mentioned below: -
- Replace getDisplayValue() --> getValue() in Line 8.
- Replace addEncodedQuery() --> addQuery() in Line 9.
Attaching Screenshot for the reference: -
New Script: -
var PopulateUsersBasedonDepartment = Class.create();
PopulateUsersBasedonDepartment.prototype = Object.extendsObject(AbstractAjaxProcessor, {
loggedInUser: function() {
var gr = new GlideRecord('sys_user');
var logged_user = gs.getUser().getRecord();
var depart = logged_user.getValue('department');
gr.addQuery('department', depart);
gr.query();
var callerUser = [];
while (gr.next()) {
callerUser.push(gr.getValue('sys_id'));
}
return 'sys_idIN' + callerUser;
},
type: 'PopulateUsersBasedonDepartment'
});
It seems to be working fine for me. Hope this time your issue gets resolved.
If you find any of the shared information/knowledge/solution helpful, please don't forget to mark my solution and reply as helpful and accepted.
Thanks :)
Aakash Garg
ServiceNow Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 05:56 AM - edited 04-10-2024 06:27 AM
Hi @shivani18
I have updated Code for SI ....
//Logic - 1
loggedInUser: function() {
var loggedUserRec = gs.getUser().getRecord();
var depart = loggedUserRec.getValue('department');
var callerUser = [];
var grRec = new GlideRecord('sys_user');
grRec.addQuery('department', depart);
grRec.query();
while (grRec.next()) {
callerUser.push(grRec.getValue('sys_id'));
}
return 'sys_idIN' + callerUser.join(',');
},
Logic - 2
loggedInUser: function() {
var depart = gs.getUser().getDepartment();
var userGr = new GlideRecord('sys_user');
userGr.addQuery('department', depart);
userGr.query();
var callerUser = [];
while (userGr.next()) {
callerUser.push(userGr.getValue('sys_id'));
}
return callerUser;
},
SS - 1
If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.
Thanks,
Subhashis Ratna