- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2018 06:54 AM
I have a requirement to hide /show tabs as a result of selection - can I achieve this through a UI policy?
Solved! Go to Solution.
- Labels:
-
Best Practices

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2018 07:11 AM
i would suggest here go with onChange() client script. if you are open with the script then try with client script rather UI policy
var sections = g_form.getSections(); // will you the sections
based on your section array index you can define like this
sections[5].style.display='block'; // hide
sections[5].style.display='none'; // not hide
note: sections[5] // 5 is the sequence of your section, make sure you mention the write sequence , it start from 0 index.
for reference you can check with below link
https://www.servicenowguru.com/scripting/client-scripts-scripting/showhide-form-section/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2018 06:57 AM
You would have to use the script tab of the UI Policy: execute if true, execute if false.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2018 07:03 AM
Do you have an example? - I am not a scripter (but I can change scripts:))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2018 04:15 AM
Example (not tested) - modify to your field/value needs:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === '') {
return;
}
if (newValue == "true") {
g_form.setSectionDisplay('related_notes', false);
} else {
g_form.setSectionDisplay('related_notes', true);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2018 07:11 AM
i would suggest here go with onChange() client script. if you are open with the script then try with client script rather UI policy
var sections = g_form.getSections(); // will you the sections
based on your section array index you can define like this
sections[5].style.display='block'; // hide
sections[5].style.display='none'; // not hide
note: sections[5] // 5 is the sequence of your section, make sure you mention the write sequence , it start from 0 index.
for reference you can check with below link
https://www.servicenowguru.com/scripting/client-scripts-scripting/showhide-form-section/