how to dot walk in script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2022 05:12 AM
Hi all,
I'm little bit confused, like how to link the fields from 2 different tables.
Ex: sys_user & cmn_location. In user table i can able to see city & country fields but the field names are populating as location for both. In this case I want to get those particular 2 fields from location table. How I do that in script include?
Sys_user > city want to get from cmn_location > city
Need some detailed understanding. Your inputs helps me to do this thing.
Regards,
Sweety.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2022 05:33 AM
Hi,
it would be nice if you share the script you are using
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2022 05:37 AM
Hello Ankur,
var displaydetails = Class.create();
displaydetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
details: function() {
var user = this.getparameter('sysparm_select');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', user);
gr.query();
if (gr.next) {
var json = new global.JSON();
var obj = {
'ucity': gr.getDisplayValue('city'), // in place of city what is the field name have to pass
'ucountry': gr.getDisplayValue('country') // same for country too
};
var data = json.encode(obj);
return data;
}
},
type: 'displaydetails'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2022 06:36 AM
Hi,
since you are saying city is from location table you can do this
var displaydetails = Class.create();
displaydetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
details: function() {
var user = this.getparameter('sysparm_select');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', user);
gr.query();
if (gr.next) {
var obj = {
'ucity': gr.location.city.toString(), // in place of city what is the field name have to pass
'ucountry': gr.location.country.toString() // same for country too
};
return JSON.stringify(obj);
}
},
type: 'displaydetails'
});
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2022 05:48 AM
Hi,
What I understood is you wanna get the city and location from user table then below are the changes -
var obj = {
'ucity': gr.location.city.getDisplayValue();
'ucountry': gr.location.country.getDisplayValue();
};
Mark this as Helpful/Correct, if Applicable.
Regards,
Sourabh