How to hide a related list tab based on some condition

Harsha21
Kilo Contributor

There is a requirement where when state is in New, I want to hide a particular related list

1 ACCEPTED SOLUTION

Chandra Sekhar6
Tera Guru

Hello,

Please write the following code in the client script, I have written on OnLoad type

You can write based on your requirement

function onLoad() {
//Type appropriate comment here, and begin script below
if(g_form.getValue('state') == 1)
{
g_form.hideRelatedList('related list name');
}

}

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

something like this in onLoad client script

function onLoad(){
	
	if(g_form.getValue('state') == 'new'){
		g_form.hideRelatedList('task_ci');
	}
	
}

Hiding Related Lists and Embedded Lists

Regards
Ankur

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

Hi Ankur, This code is not working

Hi,

Did you mistakenly marked other response as correct?

The sample code was already shared in my 1st response. you were supposed to enhance it as per your requirement.

Would you mind marking my response as correct as it was the 1st correct response to your question?

regards
Ankur

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

Chandra Sekhar6
Tera Guru

Hello,

Please write the following code in the client script, I have written on OnLoad type

You can write based on your requirement

function onLoad() {
//Type appropriate comment here, and begin script below
if(g_form.getValue('state') == 1)
{
g_form.hideRelatedList('related list name');
}

}