The CreatorCon Call for Content is officially open! Get started here.

How to hide "Related List" in Form

E555
Tera Guru

How to Hide the "Related List" at the Bottom of a Form in ServiceNow Portal for a Specific View?

 

E555_0-1739868251543.png

 

1 ACCEPTED SOLUTION

raj chavan
Tera Guru
Tera Guru

Hi @E555 

To hide the related list Add the below code in the Execute if True script section. g_form.hideRelatedList ('related_list_table_name'); To show the related list Add the below code in the Execute if False script section. g_form.showRelatedList ('related_list_table_name');

 

 

Kindly mark it correct and helpful if it is applicable.

Thanks,

Raj

View solution in original post

4 REPLIES 4

Mohammed_Iqbal
Tera Guru

Hi @E555,

 

You can also use a Client Script to dynamically hide related lists only when the form is loaded in the Service Portal and for a specific view.

 

Create new client script

Type -- onLoad

UI Type: All

Script:

 

function onLoad() {
    // Check if we are in the Service Portal
    if (window.NOW && window.NOW.hasOwnProperty('sp')) {
        setTimeout(function () {
            var targetView = "your_view_name"; // Replace with the actual view name

            // Get the current view in Service Portal
            if (window.NOW.sp.view && window.NOW.sp.view === targetView) {
                // Hide Related Lists
                var relatedLists = document.querySelectorAll('div.related_lists_container, div#related_lists');
                relatedLists.forEach(function(element) {
                    element.style.display = 'none';
                });
            }
        }, 1000); 
    }
}

 

New Developer_S
Giga Sage

Hi @E555 ,


this KB Article might help you .
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0812544.

please mark my answer helpful if it works for you.

 

regards,

Hanu

 

raj chavan
Tera Guru
Tera Guru

Hi @E555 

To hide the related list Add the below code in the Execute if True script section. g_form.hideRelatedList ('related_list_table_name'); To show the related list Add the below code in the Execute if False script section. g_form.showRelatedList ('related_list_table_name');

 

 

Kindly mark it correct and helpful if it is applicable.

Thanks,

Raj

I put this into an onload client script specifying a particular view, and it worked perfectly! Thank you all.