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

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

Ankur Bawiskar
Tera Patron
Tera Patron

@kjain 

Hope you are doing good.

Let me know if I have answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards
Ankur

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

Hi @Ankur Bawiskar ,

Unfortunately it is working only on incident, problem section.

It is not working on affected CI, Requested items  related list .

Also the section is not working on few of the sections.

I have written proper syntax and table name.

g_form.setDisplay('opened_by',false);
g_form.setDisplay('u_owner', false);
g_form.setDisplay('u_business_process', false);
g_form.setDisplay('u_delivery_approval', false);
g_form.setDisplay('approval', false);
//g_form.setSectionDisplay('Manualapproval', false); // name of section
g_form.hideRelatedList('incident'); // name of related list
g_form.hideRelatedList('problem');
g_form.hideRelatedList('change_request');
g_from.hideReleatedList('sc_req_item');
g_form.hideRelatedList('task_sla');
g_form.hideRelatedList('task_ci');
g_form.hideRelatedList('sysapproval_approver');
g_form.setDisplay('u_vendor_id_reference', false);

@kjain 

if the name is proper then it should work

Can you share for which form it is not working

Regards
Ankur

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

@Ankur Bawiskar 

Also if I write a UI policy or Client script when the form is loading at that moment it shows all the fields and once the form is loaded it shows the correct ones. so how can we fix this ? Do we need to use a BR instead?

On the Requested Item form below are not working, Also attaching the screenshot below:

g_from.hideReleatedList('sc_req_item');
g_form.hideRelatedList('task_sla');
g_form.hideRelatedList('task_ci');
g_form.hideRelatedList('sysapproval_approver');

g_form.setSectionDisplay('Manualapproval', false)

find_real_file.pngfind_real_file.png

 

Thanks!