How to hide related list based on condition?

RAM75
Tera Contributor

How to hide related list based on condition?

My Scenario: We have form Shipment form that Shipment form don't have requests then hide requests related list?

Shipment form don't have request ID (filed or variable)but Request having Shipment ID (field).

Please provide any examples.

Thanks

 

1 ACCEPTED SOLUTION

Pranesh072
Mega Sage
Mega Sage
7 REPLIES 7

You need to write OnLoad Client script as below to hide related list all the time.

 

If you need to hide It based on condition(s), you need to use the combination of UI Policy + Script

 

g_form.hideRelatedList('name of the related list');

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

So there is Shipment Form which contains a field to hold Request?

Is Request a field on Shipment table?

You can try to hide it using the script mentioned by others but only when the field is empty

function onLoad(){

if(g_form.getValue('requestField') == ''){

g_form.hideRelatedList('name of the related list');

}

}

Regards
Ankur

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

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

If not, please let us know if you need some more assistance.

Thanks!
Ankur

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