We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

how to use query inside another query

Srvs
Kilo Guru

Hi Team,

caller_id is a reference field, for that caller_id we can able to match only sys_id

please suggest me how to achive gr.addQuery('caller_id', gr2.u_partner_name);

how can i get name of the caller_id?, please suggest

 

//Incident
var arr = [];
var gr2 = new GlideRecord('u_impacted_customers');
gr2.addQuery('sys_id', '01005b5a8738251042b162473cbb3511');
gr2.query();
while (gr2.next()) {
gs.info(gr2.u_partner_name);
var gr = new GlideRecord('incident');
gr.addEncodedQuery('stateIN1,2,3');
//var test=gr.getValue('caller_id');
gr.addQuery('caller_id', gr2.u_partner_name);
gr.query();
while(gr.next()) {
gs.info(gr.number);
}
//gs.info(arr);
}

 

Regards,

Srvs.

2 REPLIES 2

Not applicable

Not applicable

@Srvs I believe gr2.u_partner_name, will be also refrence field for your custom table, if so you can use gr2.getValue('u_partner_namr') because some time this just gives object instead of providing value.

You can use dot walk in glide record as well, for you, gr.addQuery('caller_id.field_name'....

Hope this will help.