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 

Please try to login now, it will work . The account was locked earlier.

How is it working for Affected CI and approvals now?

what did you do to fix the issue?

Thanks!

@Ankur Bawiskar 

How is it working for Affected CI and approvals now?

what did you do to fix the issue?

Thanks!

Hi,

there was error in this line; so it was breaking and not executing next lines

g_from.hideReleatedList('sc_req_item'); // it should be g_form
g_form.hideRelatedList('task_sla');
g_form.hideRelatedList('task_ci');
g_form.hideRelatedList('sysapproval_approver');

Regards
Ankur

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

@Ankur Bawiskar 

 It does not work on my main instance:(

 

@Ankur Bawiskar 

Below is my code :

if (g_form.getValue('cat_item') == 'sys_id')
{
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.setDisplay('u_created_by_servicedesk', false);
g_form.setDisplay('u_left_from_servicedesk', false);
g_form.setDisplay('u_request_type', false);
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('manual_approval', false);
g_form.setSectionDisplay('related_records', false);
g_form.hideRelatedList('incident'); // name of related list
g_form.hideRelatedList('problem');
g_form.hideRelatedList('change_request');
g_form.hideReleatedList('sc_req_item');
g_form.hideRelatedList('task_sla');
g_form.hideRelatedList('task_ci');
g_form.hideRelatedList('sysapproval_approver');

}
}

 

Thanks!