- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2020 07:07 AM
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.
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2020 08:01 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2020 03:02 AM
Hi,
So which are hiding now and which aren't.
please compare the names are proper and whether those related list are actually present on the form via configure related list
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2020 03:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2020 03:54 AM
Hi,
please check any other browser console error?
If it worked fine in your instance then please add alert after every line and you will know where script is breaking
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);
alert('before hiding incident');
g_form.hideRelatedList('incident'); // name of related list
alert('before hiding problem');
g_form.hideRelatedList('problem');
alert('before hiding change request');
g_form.hideRelatedList('change_request');
alert('before hiding RITM');
g_form.hideReleatedList('sc_req_item');
alert('before hiding task sla');
g_form.hideRelatedList('task_sla');
alert('before hiding task ci');
g_form.hideRelatedList('task_ci');
alert('before hiding approval');
g_form.hideRelatedList('sysapproval_approver');
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2020 12:02 AM
Hope you are doing good.
Let me know if I have answered your question.
If so, please mark appropriate answer as correct & helpful to close the thread.
If not, please let us know if you need some more assistance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2020 01:22 AM
Hi
I moved few lines of the code up and then it is working for all except the related list "Requested Item"
Also when using a UI policy/Client script when loading the form it initially displays all the fields and after fraction of seconds hides the fields etc which is mentioned in the UI policy or Client script.
Do you know why does this happen?
Thanks!
Komal