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 09:51 AM
Can I try some thing like this, I don't know is this the acceptable or not. I'm thinking some thing to do like this. Can anyone suggest me.
var displaydetails = Class.create();
displaydetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
details: function() {
var user = this.getparameter('sysparm_select');
gs.log('1234 Received user :' + user);
var gr1 = new GlideRecord('sys_user');
var gr2 = new GlideRecord('cmn_location');
gr1.addQuery('sys_id', user);
gr2.addQuery('sys_id', user);
gr1.query();
if (gr1.next) {
gs.log('1234 record found City :' + gr1.gr2.city.toString());
gs.log('1234 record found country :' + gr1.gr2.country.toString());
var obj = {
'ucity': gr1.gr2.city.toString(),
'ucountry': gr1.gr2.country.toString()
};
return JSON.stringify(obj);
}
},
type: 'displaydetails'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2022 10:04 PM
You people are suggest me several answers but those are not working for me, can you please check and let me know about the above mentioned approach?
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2022 05:57 AM
Hey,
The above approach is not correct, you don't need to query "cmn_location" table.
Below article has the code you are looking for:
https://community.servicenow.com/community?id=community_question&sys_id=877dc4fedbabe410b1b102d5ca9619cd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2022 06:30 AM
Hi Aman,
In my case dot walking is not working. By using this can't able to display the values.
I have to take the location from sys_user table by using the reference of location table need to get the city and country. Is there any approach to glide the two tables??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2022 06:43 AM
Speaking from my experience, it should work.
And you have already 9 questions in last few days and you have not marked a single answer as correct, didn't you get any resolution for any of the questions?
What is it that the community is not able to convey or help you out?