Dynamically hide Related Lists in ServiceNow

Say you wanted to hide this Incident Tasks related list using a client script based on some business logic, how would you do it?

I have a fairly simple solution for you, first of all, find the List Name by using developer tools in your browser (usually F12).

The first part we ignore, as it is the current table our related list is sitting on.

Next, create an onLoad client script, add any business logic necessary to dictate when the lists should show or hide, then include the following lines of code in order to either Show or Hide the list. That's it!

g_form.showRelatedList('incident_task.incident_list');
Show a Related List
g_form.hideRelatedList('incident_task.incident_list');
Hide a Related List