- 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
‎03-21-2019 08:16 PM
I was recently able to do this using a UI Policy. I spent hours figuring out a lengthy client script. I eventually got it. Then realized this was faster and easier to maintain.
On the When to apply tab, add your conditions.
On the Script tab, select "Run Scripts" then enter the following
Execute if True
function onCondition() {
g_form.setSectionDisplay('insert_firsttabnamehere', true);
g_form.setSectionDisplay('insert_secondtabnamehere', true);
}
Execute if False
function onCondition() {
g_form.setSectionDisplay('insert_firsttabnamehere', false);
g_form.setSectionDisplay('insert_secondtabnamehere', false);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2020 12:40 PM
I think that both the client script and UI policy are valid options.
However, to your point I think that if you decide to go the client script direction you will have to create two separate client scripts. There will be an OnLoad script as well as an OnChange client script.
Whereas If you go the UI policy route you will have the condition evaluated on load as well as on change. Therefore it satisfies both conditions and saves you the effort of creating and maintaining two separate client scripts .