How to hide a Related Tab and sections from the RITM form using a UI Policy script.

kjain
Giga Expert

How to hide a Related Tab and sections  from the RITM form using a UI Policy script.

when a particular catalog item is used, the the RITM generated should hide few of the fields, sections and related list and tabs on the form.

find_real_file.png

 

 I have written the code like below in UI Policy Run script

function onCondition() {
g_form.setDisplay('request', false);
g_form.setDisplay('location', false);
g_form.setDisplay('cmdb_ci', false);
g_form.setDisplay('priority', false);
g_form.setDisplay('u_ritm_category', false);

g_form.hideRelatedList('u_vendor_id_reference', true);
//g_form.setDisplay('u_vendor_id_reference', false);

 

Thanks!

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@kjain 

the correct syntax to hide/show section and related list is below

g_form.setSectionDisplay('schedule', false); // name of section

g_form.showRelatedList('task_ci'); // name of related list

g_form.hideRelatedList('task_ci'); // name of related list

check below links for help

Show/Hide Form Section by Name

Hiding Related Lists and Embedded Lists

Regards
Ankur

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

View solution in original post

27 REPLIES 27

Matthew Smith
Kilo Sage

Hi

Untested, but the Docs site shows the hideRelatedList function does not accept a boolean parameter. Give this a try instead:

g_form.setSectionDisplay('manual_approval', false);
g_form.hideRelatedList('u_vendor_id_reference');

- Matt

Suseela Peddise
Kilo Sage

Hi,

As per the screen shot, Vendor ID References is a embedded list. So use below code to hide embedded list. 

Make sure you uncheck Isolate Script field i.e set isolate script field to false on client script/UI policy. 

var list = $$('div[tab_caption="Vendor ID References"]')[0];
if(list.hasClassName('embedded')){
list.hide();
}

For hiding related list

g_form.hideRelatedList('<<related list name>>'); //replace the related list name

Please see below link for more information

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

 

Hope this helps!

If I have answered your question, please mark my response as correct and/or helpful.

Thanks,

Suseela P.

@kjain ,


Just checking on this one. 

Has this question been answered or is there more information I can help you with? 

If it's been answered, please mark my answer above as the correct one so people know this has been taken care and thread will be closed. 

 

Thanks,

Suseela P.

@Suseela Peddisetty 

I tried the code: but it did not work .

var list = $$('div[tab_caption="Vendor ID References"]')[0];
if(list.hasClassName('embedded')){
list.hide();
}

 

Thanks!