how to query in a related list ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 07:57 AM
Hi All,
I have created a related list in a customer table (eg:coco-cola) called "Subscriptions" that is referring to a "subscription table". I need to get the users name who subscribed to that particular record(coco-cola). The only condition to query is "display name contains the customer name (coco-cola)" how do i write the query condition in my related list script.???
Script which i wrote:
-------------------------
(function refineQuery(current, parent) {
current.addQuery('subscription', parent.profile );
})(current, parent);
This script is fetching all the values from the table. So how do i write the query condition to get the records in which the "display name contains my customer name"(u_customer_name)??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 08:10 AM
Hi Revathy,
Refer below links which would be helpful to you:
http://wiki.servicenow.com/index.php?title=Creating_Defined_Related_Lists#gsc.tab=0
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 01:05 PM
I found this particular line from the wiki article useful:
- When scripting your condition, current is the record to which you want to add queries while parent is the main record being displayed.
I was having the same issue and had to switch the variable names. Then the Query worked properly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2019 10:49 AM
Boom. This, right here. Your comment saved me a lot of time in debugging. I was using current.field instead of parent.field until I read your comment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 07:47 AM
Hi Revathy,
Any update on this?
Can you mark answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps people to find similar question easily. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader