- 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
08-25-2020 07:15 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2020 07:28 AM
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
Hope this helps!
If I have answered your question, please mark my response as correct and/or helpful.
Thanks,
Suseela P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2020 06:15 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2020 09:01 PM
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!