How to hide a related Lists based on certain condition

Alon Grod
Tera Expert

Hi,

 

I have the field 'Master' of type True/False and I have the related list 'Software Installation'.

Im trying to Hide the related list if Master is False using onLoad Client Script.

What am I doing wrong?

 

function onLoad() {
var epc = g_form.getValue('u_master');
if (epc=='false') {
g_form.hideRelatedList('Software Installation');

}

 

Screen Shot 2023-01-02 at 12.06.20.png

 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @Alon Grod ,

You create UI policy to show and hide the related list based on condition

Go through the below link :-

https://www.servicenowguru.com/scripting/client-scripts-scripting/hiding-related-lists-embedded-list...

Sample Example :

Create UI Policy for the form with condition as field 'Action' is No.

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');

Note: Get the related_list_table_name from thee list control of the related list. Right click related list header > Personalize/Configure List Control. Copy the value from the field 'Related list'

 

View solution in original post

2 REPLIES 2

Community Alums
Not applicable

Hi @Alon Grod ,

You create UI policy to show and hide the related list based on condition

Go through the below link :-

https://www.servicenowguru.com/scripting/client-scripts-scripting/hiding-related-lists-embedded-list...

Sample Example :

Create UI Policy for the form with condition as field 'Action' is No.

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');

Note: Get the related_list_table_name from thee list control of the related list. Right click related list header > Personalize/Configure List Control. Copy the value from the field 'Related list'

 

AbdulRahim Shai
Tera Expert

Hello Alon,

You can use UI policy-related list actions to fulfill your requirement.

AbdulRahimShai_0-1672654680617.png

 

Thanks,

AbdulRahim