how to use query inside another query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 05:28 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 06:00 AM
Hi @Srvs ,
Check the best practice : https://www.servicenow.com/community/developer-blog/nested-gliderecords-are-killing-your-app-perform...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 08:06 PM
@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.