Hiding a Related List from the Layout Form

Elias11
Giga Expert

Hi Experts

I need to hide a related list from a Form which I have added it as a form Layout an dnot as a related list,

I have a section and in this section I wanted to add this related list. I right click and Personilize form and add this List.

now I need to hide this list and show it only if the field above showing YES.

I have tried in the Client script and UI Policies with
g_form.showRelatedList('u_other_employee.u_change');

OR

g_form.setVisible('u_other_employee.u_change', false);

But nothing happens.

BTW I got the name of the related list from the List control Value.

if I add this list from the related list layout the script works and I can hide it, but why it doenst work when it is from the Form ?

anyone has an idea?

Thanks

Elias

1 ACCEPTED SOLUTION

If you say that you are using a related list in a section, i think you mean embedded list.



Check this link, it explains how you can controlvisibility of related lists and embedded lists both


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


-Anurag

View solution in original post

6 REPLIES 6

Harish Murikina
Tera Guru

I just tried this below code to show and hide "Task SLA" related list


Hide: g_form.hideRelatedList('task_sla.task');


Show : g_form.showRelatedList('task_sla.task');



Check is any other Ui policy over riding this hide and show option.


Elias11
Giga Expert

Thanks for your quick response.



Yes I have checked all Policies and I do not override it, the problem is not the policy itself as if I add this list from the related list layout and not from the Form Layout the policy or clientscript will work.


You can hide the section if you want..



var sections = g_form.getSections();


var summary= sections[0];     //you have to catch the right section here


summary.style.display = 'block';     //to show


summary.style.display = 'none';   //to hide.




And if you are using a related list then you can use what Harish showed.


-Anurag

Elias11
Giga Expert

I do not want to hide a section completly , I need only to hide one related list but which I add it on the section. and not on the form completly.


maybe my issue is only that I do not catch the related list correctly.


please tell me what is the diffrence between adding a related list from the list layout and a related list adding it from the form layout?



I am using this code:


g_form.showRelatedList('u_other_employee.u_change');



but maybe it is not the right name of the form list.