Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Hide Related list using UI Policy

NaveenB44866094
Tera Contributor

Hi,
I have created a single related list and dragged above the page inside an annotation. But i can't hide and show the related list using g_form.hideRelatedList(); g_form.showRelatedList respectively in UI Policy /Client Script. 

I have referred this doc, but can't able to find solution :
https://servicenowguru.com/client-scripts-scripting/hiding-related-lists-embedded-lists/

Based on the Type of Bill Entry Filed i need to show the related list below

NaveenB44866094_0-1739975771692.png

 

 

10 REPLIES 10

Naveenbabu1531
Tera Contributor

Naveenbabu1531_0-1739977466766.png

I've used annotation to build this form.

Ankur Bawiskar
Tera Patron
Tera Patron

@NaveenB44866094 

it's not a related list, you have added it as Embedded list on your form.

g_form.hideRelatedList() -> won't work on embedded list

2 ways to approach this

1) either use DOM manipulation and hide it, I won't recommend this as it's not best practice

How to hide an embedded list using a client script or UI Policy 

OR

2) Add that embedded list on some form section and then hide that section

g_form.setSectionDisplay("embedded_listsection",false);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Naveenbabu1531
Tera Contributor

I've tried below method, but its not working

g_form.setSectionDisplay("embedded_listsection",false);

 

@NaveenB44866094 @Naveenbabu1531 

Did you give correct section name? script or logic I shared should work fine

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

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

Naveenbabu1531
Tera Contributor

I've tired both the methods, but i can't able to hide the section.
This is the client script i have written

Naveenbabu1531_0-1740026765230.png