Script Include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 05:01 AM
Hi,
I want to filter a ref field based on another field(Ref). If that field.name contains XXXX, then the 2nd field will show all records where field.comany.name contains XXXX. Below returning all records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 06:09 AM
javascript:if(current.select_buying_agent_account.name.indexOf("CASA") >= 0) 'company.nameCONTAINSCASA';else 'company.nameCONTAINSLi & Fung';
this returning list contains Li & Fung only.
Can you help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 08:13 AM
I mean in your script include, do the if/else and return the encoded query instead of the getting the sys_id query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 08:23 AM - edited 12-05-2023 08:24 AM
HI @Rosy14 ,
I trust you are dioing great.
Please find th eupdated code
function asda_getContactBasedOnAccount() {
var ContactArray = [];
var accName = current.select_buying_agent_account.name.toString();
var gr = new GlideRecord('customer_contact');
if (accName.indexOf("XXXX") >= 0) { // Replace "XXXX" with the specific string you're checking for
// Dynamically filter based on the accName value
gr.addEncodedQuery("company.nameCONTAINS" + accName);
} else {
// Optionally, handle the case where "XXXX" is not found in accName
// You can remove this else block if it's not needed
gr.addEncodedQuery("company.nameCONTAINSdefault_value"); // Replace "default_value" with a default string if needed
}
gr.query();
while (gr.next()) {
ContactArray.push(gr.sys_id.toString());
}
return ContactArray;
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 08:31 AM
javascript:var rt='';if(current.variables.select_buying_agent_account.name.toString().indexOf("CASA") >= 0) rt='company.nameCONTAINSCASA';else rt='company.nameCONTAINSLi & Fung';rt;
Inside Ref qual it is working.