- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2022 09:14 PM
Hi experts,
I've a related list defined on a table. I would like to show this tab only on certain conditions. What would be the best way to achieve this? The screenshot below should define what I'm trying to do
One way I can think of is making this return 0 rows so that I can then go to "Right Click->Configure Control->Omit if no records"
But I would be all for not having to query that table at all since it contains 3M+ records and querying through such a large dataset is delaying loading of form on the parent table
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 01:59 AM
Do this
parent object gives you access to current form field values
if(parent.status.toString() == 'active'){
// use your query to show
}
else{
current.addQuery("sys_id", "-1"); // no records returned using this
}
Regards
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
02-13-2022 11:29 PM
I tried it and the form view is taking time to load. It does hide the related list tab but the source table was queried too.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2022 11:26 PM
Hi,
Based on all your replies to all the other threads, it seems your main concern is performance of loading the form, since querying a large table.
You are asking if you could eliminate the loading of the related list on the form if the query returns 0 results, and would like to optimize so that the loading of the related list never happens if not returning any results.
The issue is that query must first take place to get a result on however there are any results to return or not. I don't believe there is a way to do a refined query based on an input parameter like you are trying.
As for performance issues regarding loading related lists on a form, there is a user preference that might help you;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2022 11:33 PM
Hi OlaN,
Thanks for the suggestion. I'm aware of the preference but the thing is I can't suggest the same to a set of Agents who will be logging into the instance. Reason being while it will solve the issue of form load, when the Agent wants to see the related list, it would still be a time consuming activity when he/she clicks on "Show Related List" button.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 12:00 AM
Hi,
Can you explain the details of the current form and Related List which you have configured and also on what conditions you do not want the application to stop query?
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 01:26 AM
I've given some details in the reply to Ankur below. Does that help?