- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2020 07:11 AM
I have a variable on a catalogue item that references the locations table. I want that variable to only list locations whose parent = the signed in user's location. EXCEPT if the signed in User's location = MG. If the signed in user's location is MG then I want the variable to list all locations on the table.
function advloc() {
var locPar;
var userLoc='';
var gr=new GlideRecord('sys_user');
gr.addQuery('sys_id',gs.getUserID());
gr.query();
while(gr.next()){
userLoc=gr.location;
}
if(userLoc.includes("MG")){
locPar = "";
}
else {
locPar = "parent = userLoc";
}
return locPar
}
I think it is not working because it returns the name of the location and not the Sys_Id, but I'm not 100%.
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2020 07:39 AM
You're on the right track. That script belongs in a script include that is client callable:
And in your reference qualifier you would just do:
new getLocation().locations();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2020 07:25 AM
Where are you calling this from? For reference qualifiers you should call a script include that returns the information you want available in the field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2020 07:36 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2020 07:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2020 08:03 AM
Looks like one of the images you shared didn't load.
I put the script in a client callable script include and then called it in my reference qualifier and still no dice. 😕
I'm going to look over the script to make sure I don't have any typos.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2020 08:31 AM
I double checked and corrected my typos, but still no luck. I might just be missing something, I'm still pretty new to ServiceNow.