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

@Nisar 

Sure.

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

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

Aditya2
Kilo Expert

Hi

 

On onLoad and onChange client script after giving your conditions you can use g_form.setSectionDisplay(Related Tab name, true/false);