Using reference qualifier to filter users based on the current user's location

JordyZ
Mega Sage

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.

 

https://www.servicenow.com/community/it-service-management-forum/reference-qualifier-to-filter-locat...

1 ACCEPTED SOLUTION

Rebecca3
Tera Guru

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()

Rebecca3_2-1669808649231.png

 

Rebecca3_1-1669808506108.png

 

View solution in original post

14 REPLIES 14

Hi @Kalyani Jangam1 @Mitsua 

 

I am still getting an error even after including the two first lines. What am I doing wrong? Thank you for your patience guys.

Hi @JordyZ 

Create new SI and make client callable false and refer below

Screenshot 2022-11-30 at 4.19.36 PM.png

Try this one for new SI and let me know if it is working or not.

Hey @JordyZ 

 

In your code last line was missing. (type: 'populate_users')

I am attaching here xml of script include. 

Please check once by importing it.

 

Thanks!

Hello @JordyZ 

Please refer attached screenshot for reference. You script include look like :

Mayuri11_0-1669805167953.png

 

Reference qualifier :

 

Mayuri11_1-1669805237390.png

Please mark my response as Correct / Helpful based on Impact.

Thanks!

Hi @JordyZ 

Please refer below scrrenshot

Screenshot 2022-11-30 at 4.19.36 PM.png

Please check and mark answer correct if it will help you.