Related List and Relationship Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 09:48 PM
Hi All,
I have created related list relationship which is working fine but it shows all records. It should show only filtered records. Below is Script I have written, where could be issue why filter is not working in this case? My requirement is to use GlideRecord.
(function refineQuery(current, parent)
{
var trendword=parent.getValue('u_trendword');
var leArray=[];
var gr = new GlideRecors(sn_risk_advanced_event);
gr.addEncodedQuery('nameLIKE +trendword);
gr.query();
while(gr.next())
{
leArray.push(gr.getValue('number'));
}
current.addQuery('number','IN',leArray);
})(current,parent);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 10:15 PM
Hi @Tarasingh26 ,
Change GlideRecors-> GlideRecord.
I hope this helps!
Regards,
Hemant
**Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.**
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 10:20 PM
This is typo from my side. but in instance it is correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 10:24 PM - edited 08-21-2023 10:28 PM
You should copy/paste what you have in the actual script to make this easier. The name of the table should be in quotes on that same line. And the "addEncodedQuery" line is not terminated with a single quote. Should be "gr.addEncodedQuery('nameLIKE' + trendword);". It's hard to debug something that is not accurate to begin with.
You might also want to take a look at these 2 posts for future questions:
TNT: Screenshots Help, but Code is Better
TNT: And Formatted Code is Even Better
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 10:38 PM
It would be easier when you share screenshots so that we get to know it's applied on which table etc
try this
(function refineQuery(current, parent){
var leArray = [];
var gr = new GlideRecors('sn_risk_advanced_event');
gr.addEncodedQuery('nameLIKE' + parent.getValue('u_trendword'));
gr.query();
while(gr.next())
{
leArray.push(gr.getValue('number'));
}
current.addQuery('number','IN',leArray);
})(current,parent);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader