Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get user location with getUser

Joao Carlos1
Tera Guru

Hi,

How can i get the location of the login user with getUser and get the location? Can it be simple to add to a condition script? I need the condition like, if get user location is Peru

 

find_real_file.png

 

find_real_file.png

 

Thanks in advance,

Joao.

7 REPLIES 7

Hi,

so use this to compare the location

gs.getUser().getLocation() == 'locationSysId'

if my answer helped you, kindly mark it as Correct & 👍Helpful based on the Impact.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Mike Patel
Tera Sage

you can use something like in condition

gs.getUser().getLocation() == 'SYS_ID_of_location';

if you want just location than use (below will give you sys_id of location)

gs.getUser().getLocation();

 

Refer to below for more info functions

https://www.servicenowguru.com/scripting/user-object-cheat-sheet/

Billu
Tera Contributor

Hi,

How to get the location not sys_id.