dot walking returns undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2018 07:28 AM
Hello,
I am trying to retrieve information from a reference field but am getting "undefined"
I have tried the below so far
gs.info("!>>> country" + gr.cmn_location.u_countries.getValue('u_country'));
gs.info("!>>> country" + gr.cmn_location.u_country_cd_iso2.getValue('u_country'));
gs.info("!>>> country" + gr.Location.u_country_cd_iso2.Counry.toString);
The field in form manager looks like this
Other field on the GR return fine?
How do I retrieve information contained in reference fields?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2018 07:54 AM
Hi,
the getValue part isnt the problem I replaced it with getDisplayValue and it still wont work..
here is what I am trying to do
//get user object
var userObj = new GlideRecord('sys_user');
userObj.get('6440d3a85dbe20004abfd62e32a38932');
//get user country
var userCountry = userObj.cmn_location.u_countries.getDisplayValue('u_country'));
//when I gs.info userCountry its empty?
//look for custom table tasks for users country
var gr = new GlideRecord('cases');
gr.addQuery('u_country',userCountry );
gr.query();
while(gr.next()){
//do stuff
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2018 07:59 AM
USe below sample code
var userObj = new GlideRecord("sys_user");
userObj.get('62826bf03710200044e0bfc8bcbe5df1');
userObj.query();
gs.print(userObj.location.country);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2018 08:02 AM
why are you quering again do you need that statement.
var userObj = new GlideRecord("sys_user");
userObj.get('62826bf03710200044e0bfc8bcbe5df1');
userObj.query(); // I feel this is not needed
gs.print(userObj.location.country);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2018 08:13 AM
Here you go
//get user object
var userObj = new GlideRecord('sys_user');
userObj.get('6440d3a85dbe20004abfd62e32a38932');
//get user country
var userCountry = userObj.location.u_countries.getValue('u_country');
//when I gs.info userCountry its empty?
//look for custom table tasks for users country
if(userCountry){
var gr = new GlideRecord('cases');
gr.addQuery('u_country',userCountry );
gr.query();
while(gr.next()){
//do stuff
}
}