How to show tabs based on Condition ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2015 06:56 AM
I am working on Incident form and I am stuck at one point. I have one field named No. of screens which is of Choice type. I have added 0, 1, 2, 3, 4, and 5 as the values to the drop down and I have created five new form sections named Screen 1, Screen 2, Screen 3, Screen 4, and Screen 5 with their respective fields added to it.
Can anyone please guide me that how can I display no form section when 0 is selected from drop-down, Screen 1 form section when 1 is selected from the drop down. Screen 1, and Screen 2 tabs when 2 is selected. Screen 1, Screen 2, and Screen 3 as tabs when 3 is selected. Similar process should be followed for 4 and 5 screens selected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2015 12:51 PM
Here are some good posts that will help you:
Hiding a section of a form based on a condition
Show/Hide Form Sections if a True/False field is selected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 02:30 AM
Thank you for your suggestion Victor.
I tried implementing the same, however, I am not getting the desired result. Here is the script that I am using. Can you please assist me with it.
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
//Type appropriate comment here, and begin script below
var sections = g_form.getSections();
//Type appropriate comment here, and begin script below
var sec1= sections[7];
var sec2= sections[8];
var sec3 = sections[9];
var sec4 = sections[10];
var sec5 = sections[11];
if(g_form.getValue('u_no_of_screen') == '1')
{
sec1.style.display = 'block' ;
}
if(g_form.getValue('u_no_of_screen') == '2')
{
sec2.style.display = 'block' ;
}
if(g_form.getValue('u_no_of_screen') == '3')
{
sec3.style.display = 'block' ;
}
if(g_form.getValue('u_no_of_screen') == '4')
{
sec4.style.display = 'block' ;
}
if(g_form.getValue('u_no_of_screen') == '5')
{
sec5.style.display = 'block' ;
}
else
{
sec1.style.display = 'none' ;
sec2.style.display = 'none' ;
sec3.style.display = 'none' ;
sec4.style.display = 'none' ;
sec5.style.display = 'none' ;
}
callback(saveAndClose);
}
Thanks !!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 03:46 AM
What version of ServiceNow are you using?
Tabs can be displayed by built in API in Fuji.
Also, I'm not sure if onCellEdit is the correct event.
�ou may wish to try onChange event
14.7 setSectionDisplay
boolean setSectionDisplay(sectionName, display)
- Parameters:
- sectionName - name of the section to be shown or hidden. The section name is lower case with an underscore replacing the first space in the name, and with the remaining spaces being removed, for example "Section Four is Here" becomes "section_fourishere". Section names can be found by using the getSectionNames method.
- display - set true to show, false to hide.
- Returns:
- Boolean - true if successful.
GlideForm (g form) - ServiceNow Wiki
- Boolean - true if successful.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 04:00 AM
Also can you write the code in an onChange or onLoad client script and try.
If you are on fuji then its way better to go with the setSectionDisplay() mention by Paul Morris.