- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 12:47 AM
How to Hide the "Related List" at the Bottom of a Form in ServiceNow Portal for a Specific View?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 01:41 AM
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');
Thanks,
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 01:11 AM
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 01:41 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 01:41 AM
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');
Thanks,
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 01:52 AM
I put this into an onload client script specifying a particular view, and it worked perfectly! Thank you all.