Is it possible to show related list conditionally?

Nisar2
Mega Guru

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

find_real_file.png

 

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

1 ACCEPTED SOLUTION

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

22 REPLIES 22

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.

OlaN
Giga Sage
Giga Sage

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;

find_real_file.png

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.

shloke04
Kilo Patron

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

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

I've given some details in the reply to Ankur below. Does that help?