Can I hide a tab using a UI Policy

johnrob18
Giga Guru

I have a requirement to hide /show tabs as a result of selection - can I achieve this through a UI policy?

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

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://community.servicenow.com/community?id=community_question&sys_id=7bc5c721db1cdbc01dcaf3231f96...

https://www.servicenowguru.com/scripting/client-scripts-scripting/showhide-form-section/

View solution in original post

6 REPLIES 6

Mike Allen
Mega Sage

You would have to use the script tab of the UI Policy: execute if true, execute if false.  

Do you have an example? - I am not a scripter (but I can change scripts:))

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);
  }
}

Docs: GlideForm: setSectionDisplay()

Harsh Vardhan
Giga Patron

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://community.servicenow.com/community?id=community_question&sys_id=7bc5c721db1cdbc01dcaf3231f96...

https://www.servicenowguru.com/scripting/client-scripts-scripting/showhide-form-section/