how to dot walk in script include

Sweety11
Kilo Contributor

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.

26 REPLIES 26

Hello sourab,

It's not working. Can you suggest me the alternate ways to do it

Aman Kumar S
Kilo Patron

Try this:

var displaydetails = Class.create();
displaydetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
details: function() {
var user = this.getparameter('sysparm_select');
var obj = {};
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', user);
gr.query();
if (gr.next) {

obj.ucity = gr.location.city, // in place of city what is the field name have to pass
obj.ucountry = gr.location.country; // same for country too

}

return JSON.stringify(obj);
}

},

type: 'displaydetails'
});

 

Best Regards
Aman Kumar

Hey Aman,

I have tried it, It's not working for me

Can you show user form, how location is populated on user form

Best Regards
Aman Kumar

Here I'm adding the screenshot of user from. In this scenario I need to glide the sys_user table and cmn_location table think sooo. Can you please conform me the same.

 

Regards,

sweety.