- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2017 07:27 AM
Hello.
I have a variable in my catalog item called primary_spending_location.
I want this variable to default to the submitter country of record.
I used the "Default Value" field on the variable and set to
javascript:gs.getUser().getCountry();
This does not work. The field just remains blank. (i have ensured the logged in user has a value in the country field on their user record)
I've tried javascript:gs.getUser().getLocation(); //This works just fine
I've tried javascript:gs.getUser().getManagerName(); // This works just fine.
I've tried most of the items found here: http://wiki.servicenow.com/index.php?title=Getting_a_User_Object#gsc.tab=0 but COUNTRY does not work.
I've tried to make the field Single Line Text, and it's still blank, but the others populate the field just fine
I've tried to make the field what I actually want it to be (a Lookup Select Box to the cmn_location table "country" field), and it just always defaults to the first one in the list
Any ideas?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2017 07:45 AM
Hi Kevin,
I did a quick test and gs.getUser().getCountry() returned the value in the Country code [country] field on the user record for the logged in user. If you've just added the value to the field for testing you'll need to log out and back in or reimpersonate in order to use the value on the user object. Also note that it should return the country code, so US or UK.
Also, does this happen to be in a scoped application?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2017 07:45 AM
Hi Kevin,
I did a quick test and gs.getUser().getCountry() returned the value in the Country code [country] field on the user record for the logged in user. If you've just added the value to the field for testing you'll need to log out and back in or reimpersonate in order to use the value on the user object. Also note that it should return the country code, so US or UK.
Also, does this happen to be in a scoped application?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2017 09:29 AM
Hi Brad,
No, this is a catalog item in Global.
This is my ootb personal dev instances, so maybe there is something wrong with it. but it's not working
Set default value
Tried to look up by sys_id and name both
This is what i get when it's a look up
The country's are still a choice
When i make it a single line text field instead of a lookup select box, it's blank.
you can see for yourself here if you'd like
id: abel.tuter
pw: test

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2017 10:46 AM
Hmm...I configured that in an instance both ways and it works, even though for the lookup select I think the value and label should be the country field. I would check your browser console for any errors when you load the catalog item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 06:26 AM
Thanks Brad. I decided to try this out directly in one of my sub-instances, and it works just fine. Something wrong with the Personal Developer instances that doesn't like this function. (even wiped out, restored and upgraded...still doesn't work) What a waist of time!!
Thanks for your time. It helped a lot!