- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2021 09:09 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2021 09:27 PM
You can update the list control for the related list

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2021 02:56 AM
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');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2021 03:00 AM
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
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-23-2021 02:11 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader