- 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
08-22-2016 07:01 AM
Dear Mohamed,
Thank you!
However, I have come across a complication that may or may not be how it is supposed to work but is not how it is desired to work. We are on Fuji Patch 13 Hot Fix 1. I have a Client Script to hide a Section by Name:
function hideSectionByName(name) {
var sections = g_form.getSections();
for(var i = 0; i < sections.length; i++) {
var txtProps = '';
if (sections[i].textContent.lastIndexOf(name, 0) === 0) {
try {
//sections[i].style.display = 'none';
sections[i].remove();
}
catch (err) {
alert('Error hiding Sensitive Information Tab: ' + err.message);
}
} // if (sections[i].textContent.lastIndexOf(name, 0) === 0)
}
}
While this Client Script successfully hides the Section, it leaves the Tab visible which is less than ideal. As is implied with the commented out line, I have also tried setting the CSS Display value with no change in result. Might you or anyone else have found a solution to this?
Thank you in advance.
Respectfully,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2016 02:46 PM
Hi Similar to this
Instead of display = "none" can i do readOnly = "true". I mean i tried but its not working.
Basically Is there a way to make Form Section read only.. My requirement is to make form section readonly based on some condition

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2017 03:05 AM
Thanks Mohamed Faizeal.
In the code statement below, 4 can be replaced with n, where n can take on the following values: 0,1,2,3,4. The value n depicts the index of the form section you would like to perform the operation on:
sections[4].style.display = 'none';
Code:
function onLoad() {
var sections = g_form.getSections();
sections[4].style.display = 'none';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2015 02:17 PM
What about the tabs?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2015 12:09 PM
The Above code is applied for tab i.e., section. I have 5 tabs and i want to hide the 5th tab so wrote this code in onload and done it.