- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2020 01:08 PM
Hi Everyone,
I have a use case to display list of Locations in the Locations reference list based on the requested for company. I have written a script include and called it in an advanced qualifier as below, but it seems to be not working. Could anyone please provide any insights on why?
Thank you in advance.
Below are the screenshots
function myScriptInclude() {
var site = ' ';
var b = gs.getUser(); //Logged-in user
var loc = new GlideRecord('cmn_location');
loc.addQuery('company',b.getCompanyID());
loc.query();
while(loc.next()) {
if (site.length > 0) {
//build a comma separated string of groups if there is more than one
site += (',' + loc.company);
}
else {
site = loc.company;
}
}
// return Groups where assigned to is in those groups we use IN for lists
return 'sys_idIN' + site;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2020 07:05 PM
Hi Chaithra,
the reference variable is referring to cmn_location; but the array is storing the sys_ids of the company table
you need to push sys_id of the cmn_location table i.e.
loc.sys_id.toString()
Actually there is no need of script include you can do this in advanced reference qualifier:
javascript: 'company=' + gs.getUser().getCompanyID()
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2020 07:05 PM
Hi Chaithra,
the reference variable is referring to cmn_location; but the array is storing the sys_ids of the company table
you need to push sys_id of the cmn_location table i.e.
loc.sys_id.toString()
Actually there is no need of script include you can do this in advanced reference qualifier:
javascript: 'company=' + gs.getUser().getCompanyID()
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2020 08:51 AM
I was wrong with my syntax. Thanks a lot Ankur!! 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2020 08:51 AM
Thanks a lot everyone for your time and insights!!