The CreatorCon Call for Content is officially open! Get started here.

Form Section Hide/Show via Checkbox

Adam Kirk
Tera Contributor

I've been tasked with adding checkboxes to the standard Change Request form, to mimic an internal deployment document.  I would like to toggle the visibility of section names based on checkbox true/false status via UI Policy, but I am having no luck.  

 

1. Do the checkboxes refer to applications utilized by my company (e.g. Azure).  Do these checkboxes need to tie to the Applications table?

 

2. If not, and this can be resolved by UI Policy alone, then this is an example of what I've tried with no success.

Condition : Azure is true

var isChecked = g_form.getValue('Azure') == 'true';

// Define the conditions for hiding/showing the section
if (isChecked)
{
// Show the section
showSection('azure_changes');
}
else {
// Hide the section
"hideSection('azure_changes');"
}

function hideSection(azure_changes) {
var section = g_form.getSection(sectionName);
if (section) {
section.style.display = 'none';
}
}

function showSection(sectionName) {
var section = g_form.getSection(sectionName);
if (section) {
section.style.display = '';
}
}
})(current, previous);

 

2 REPLIES 2

SN_Learn
Kilo Patron
Kilo Patron

Hi @Adam Kirk ,

 

Please try the approach suggested in the video below and make changes as per your requirement:

Show/Hide Form sections under some conditions | UI Policies 

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Sumanth16
Kilo Patron

Hi @Adam Kirk ,

 

Please refer below thread:

https://www.servicenow.com/community/developer-articles/servicenow-form-section-hide-show-servicenow...

https://www.servicenow.com/community/developer-articles/how-to-using-ui-policies-to-hide-form-sectio...

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda