- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 02:53 AM
Hello,
I need to get the information of the logged in user. I need to know his/her department and the country's ISO value.
var deptID = gs.getUser().getRecord().getDisplayValue('department'); // works. gives me back the user's department name
var conVal = gs.getUser().getRecord().getDisplayValue('u_country'); // works. gives me back the user's country name
var ISOVal = gs.getUser().getRecord().getDisplayValue('u_country.iso3166_3'.); // NOPE, addinfomessage returns empty
iso3166_3 is a field on Country table, label is ISO Long. How do I get access to it for the logged in user?
Many thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 03:21 AM
Hi,
As far as I am aware you cannot dot walk inside a reference field. From your code it looks u_country is reference field and to get u_country.iso3166_3 which is inside the reference field it is not possible by dot walking(as dot will get you access to only the object present in that reference). Instead you can use
var gr = GlideRecord(ref_table for u_country);
gr.addQuery(sys_id,gs.getUser().getRecord().getDisplayValue('u_country'));
gr.query();
if (gr.next()){
var ISOVal = gr.iso3166_3;
}
Thanks
Thameem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 03:21 AM
Hi,
As far as I am aware you cannot dot walk inside a reference field. From your code it looks u_country is reference field and to get u_country.iso3166_3 which is inside the reference field it is not possible by dot walking(as dot will get you access to only the object present in that reference). Instead you can use
var gr = GlideRecord(ref_table for u_country);
gr.addQuery(sys_id,gs.getUser().getRecord().getDisplayValue('u_country'));
gr.query();
if (gr.next()){
var ISOVal = gr.iso3166_3;
}
Thanks
Thameem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 03:55 AM
Hello Thameem, many thanks!
With a small modification it works:
var gr = GlideRecord('core_country');
gr.addQuery('name',gs.getUser().getRecord().getDisplayValue('u_country'));
gr.query();
if (gr.next()){
var ISOVal = gr.iso3166_3;
// gs.addInfoMessage(ISOVal);
return ISOVal;
}
I can use this script in script include and set a filter with the script include name. Again, many thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2017 04:22 AM
You are Welcome!
Please mark correct if it solved your requirement
Thanks
Thameem
Link for help to mark correct
How To Mark Answers Correct From Community Inbox