- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2015 12:27 AM
Hi,
How to hide the form sections and tab using client script?
I was trying the below client script with the reference of http://www.servicenowguru.com/scripting/client-scripts-scripting/showhide-form-section/
It was not working, hope it was working fine in Eureka and we are in fuji now and it's not working in fuji, i tested in demo also, the below script not working
function onLoad() {
//Hide the section
var section = $$('span[tab_caption_raw="Questions"]')[0].select('span[id*=section.]')[0];
section.hide();
alert(section);
//Hide the tab
$$('.tab_caption_text').each(function(caption) {
if(caption.innerHTML == 'Questions'){
caption.up('.tab_header').hide();
}
});
}
Could any one please help on this?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2015 01:01 AM
I just tried the below script in Fuji, i can hide the section.
function onLoad() {
var sections = g_form.getSections();
sections[4].style.display = 'none';
}
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2015 07:08 PM
I created an on change CS but I can't get it to work, I need to hide three sections based on check box on the top of change form. Can anyone share some hints for fuji release?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2015 08:44 AM
Try the above script in onchange and let us know
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2015 08:56 AM
All good resolved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2015 01:06 AM
Hi there, i want to be able to only show a section based on the choice value of another field.(see below)
So if Leaver is selected show the Leavers tab.
I've had a crack at an onload client script but am not getting it right. As you can see i have no scripting knowledge. Any help/pointers on this please?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue == "Leaver")
{var sections = g_form.getSections();
sections[5].style.display = 'true';
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2016 03:54 AM
There is an OOTB g_form method for this, where you can use the name of the section, rather than DOM and hoping the order of the sections never changes:
g_form.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". Other non-alphanumeric characters, such as ampersand (&), are removed. Section names can be found by using the getSectionNames method.
- display - set true to show, false to hide.
- Returns:
- Boolean - true if successful.