Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

server script to retrieve Country information

Frank70
ServiceNow Employee

In order to get user information to be displayed in the header of a portal, you can use the glidesystem user object:

eg. gs.getUser().getFirstName;

This works fine if the field contains a value.  However if the field is a reference, then the gs doesn't return a value :

eg. gs.getUser().getLocation;  doesn't return the value of the location of the logged on user.

Is there a way to get the value from a reference field ?

4 REPLIES 4

Harish KM
Kilo Patron

you can use this

javascript:gs.getUser().getRecord().getDisplayValue("location");

Regards
Harish

Frank70
ServiceNow Employee

Thanks Harish,  this indeed works.

Do you also know how to get the country value ? (from the reference location => Country)

 

The variable is referenced to location table or country table?

if country you can do this

javascript:gs.getUser().getRecord().getDisplayValue("country");

Regards
Harish

Frank70
ServiceNow Employee

the country value is located in the location table, which is referenced in the user table.

Your suggestion doesn't work.

So it is dot walking a level deeper.