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

How to hide a related list if field is set to certain value

LyndseySharpe
Tera Contributor

Hi all,

 

I'm trying to hide the related list 'vendor catalogue items' on the company table whenever the form is loaded, if the approval status field is set to none or approved, and the vendor field is ticked. I've attached a screenshot here showing these details, circling the two fields on the company form that should determine if the related list is visible or not, and also the related list I'm trying to hide. I've also attached a screenshot showing my catalogue UI policy I've created, that isn't working. I've tried what's in this article below, and no luck! Anyone got any ideas or had something similar?

Solved: How do I hide a related list on load? - ServiceNow Community

Thanks!

Vendor fields condition is based on.jpg

LyndseySharpe_1-1671035639018.jpeg

LyndseySharpe_2-1671035659400.jpeg

LyndseySharpe_4-1671035698704.jpeg

 

 

 

1 ACCEPTED SOLUTION

Muhammad Khan
Mega Sage

Rather than using script you can utilize UI Policy Related List Action.

UI Policy

MuhammadKhan_0-1671036841136.png

 

UI Policy Related List Action

MuhammadKhan_1-1671036892454.png

 

 

View solution in original post

7 REPLIES 7

Taha Habib
Tera Guru

Hello LyndseySharpe,

As per your description "I'm trying to hide the related list 'vendor catalogue items' on the company table whenever the form is loaded, if the approval status field is set to none or approved, and the vendor field is ticked."

I believe you are trying to hide the related list when the conditions are met. However, in the script in "Execute if True" Part, you are doing showrelatedlist, instead of hideRelatedList.

Example:

TahaHabib_0-1671038151755.png

 




Srikanth Bitra
Tera Contributor

Hi,

 

As per the say, your condition is "whenever the form is loaded, if the approval status field is set to none or approved, and the vendor field is ticked." But as per the screenshot, the approval status is "pending approval". So it's not hiding.

 

Solution: Please make the approval status none or approved and make Reverse if True as ticked. And for the scripting part as 

 

Execute if true: g_form.hideRelatedList('pc_vendor_cat_item');

Execute if false as: g_form.showRelatedList('pc_vendor_cat_item');

 

Regards,

Srikanth

LyndseySharpe
Tera Contributor

Thank you everyone else 🙂 I actually wrote it incorrectly in my question 🙈 I meant to say I'm trying to hide the related list when the approval status is NOT approved or null. It was supposed to be visible for approved or null, so my script appeared correct. Not sure why it wasn't working but using the ui related lists tab worked 🙂