Hide/show related list

brown9394
Tera Expert

Hi Experts,

I have a related list I'm wanting to hide through UI Policy when state 'is one of' draft, pending, WIP. I've been able to do this before via getting the related list value from List Control and putting it directly in the UI Policy Script. I've set my 'when to run' conditions in place and I have the 'onLoad' checked, and 'reverse if possible' checked. Not sure why this isn't working.

function onCondition() {

  g_form.hideRelatedList('REL:7bb4a2e0134e6e001b8f3598d144b03b');

}

function onCondition() {

  g_form.showRelatedList('REL:7bb4a2e0134e6e001b8f3598d144b03b');

}

1 ACCEPTED SOLUTION

That would be an embedded list James. The function you are using wouldn't work for that. Refer to this link: Hiding Related Lists and Embedded Lists - ServiceNow Guru


View solution in original post

9 REPLIES 9

sorry, i did not get you point? could you please tell me more


That would be an embedded list James. The function you are using wouldn't work for that. Refer to this link: Hiding Related Lists and Embedded Lists - ServiceNow Guru


Thank! Now that we figured that out and it works, the team wants to take another approach since we have a lot of embedded lists to hide, is it possible to do it through onChange client script?


Related lists are configured using configure - related lists. The lists you bring to form using Form Layout would be embedded lists. They are essentially the same but in the simplest terms, related lists have more control options, and embedded lists can be placed anywhere on the form within a section.


agrawars
Tera Contributor

If nothing works, then try below code in UI Policy

 

function onCondition() {
        addLoadEvent(hideIncidents);
       

        function hideIncidents(){
            g_form.hideRelatedList('incident'); // Table name of related list
         }
}