- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 01:51 AM
Hi, I have a variable on a catalogue item that references the sys_user table. I'd like that variable to only show the users that are in the same location as the current user's location (i.e current user is European so he will only see European users). How do I do this with reference qualifier?
I've found a post that resembles this problem, but not entirely. I'm new to ServiceNow, so I don't know yet how to tweak the answer to fit my specific case.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 03:43 AM - edited 11-30-2022 03:46 AM
There is a much easier way to do this, without requiring a script include.
gs.getUser().getLocation() returns the location of the logged in user. In the reference qualifier of your variable, you can use it as follows -
javascript:gs.getUser().getLocation()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 03:43 AM - edited 11-30-2022 03:46 AM
There is a much easier way to do this, without requiring a script include.
gs.getUser().getLocation() returns the location of the logged in user. In the reference qualifier of your variable, you can use it as follows -
javascript:gs.getUser().getLocation()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 05:10 AM
Hello @Rebecca3 ,
Thanks for your reply. When I try this, and test the variable, no caller comes up. My user has location set as Brussels-Belgium, I'd like it to show all users from Europe. Any tips?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 05:32 AM
Hi Jordy,
You mentioned the same location so I assumed the value in the location field would be the same - are you currently storing somewhere which locations are in Europe?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 07:38 AM - edited 11-30-2022 07:38 AM
Hey @Rebecca3 ,
Yes it is stored somewhere but I'm not sure where to find it, I will get back to you once I do.
In the meanwhile I tried the solution you've provided above for same location, I'm not sure what went wrong but even if I set my location to the same as another user, I don't see that user when I test the variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 12:36 AM - edited 12-01-2022 12:36 AM
Hi @Rebecca3 ,
This is what I was able to find out about the region. "region and country are stored in the location table with a parent child link. For the filter on the location of the connected user, it's the region (but the region is stored in the location field of the user) So user from a region see only users from his region."