Show/Hide Form Section
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2013 01:26 PM
Does anyone know how to Hide/Show a form section based on a field. I attempted to follow the example below from the wiki, but it did not work for me. See attached.
function onChange(control, oldValue, newValue, isLoading) {
//this example was run on a form divided into sections (Change form)
// and hid a section when the "state" field was changed
var sections = g_form.getSections();
if (newValue == '2') {
sections[1].style.display = 'none';
} else {
sections[1].style.display = 'block';
}
}
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#Form_Information_Methods
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2013 11:12 PM
Hi Wamiq,
I have done the same thing on https://demo019.service-now.com/navpage.do on incident table.
Please refer below code for doing the needful :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var sections = g_form.getSections();
if (newValue == 6) {
sections[4].style.display = 'block';
} else {
sections[4].style.display = 'none';
}
}
// Onchange script is running on "State" field. Here '6' is the database value for state - "Resolved" on incident form. And '4' is the array position of section - 'xyz'.
Please check in your script if you are mentioning the correct database value for Resolved State and correct array position of section.
Regards/Neetu
Happy to help!!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2013 12:38 AM
Thanks Neetu.
It's working now. Any logic how we get the correct index number?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2013 12:49 AM
Hi Wamiq,
We can get the correct index number for the sections from the Forms Module. Type 'forms' in application navigator, then look for incident table, here you can see all the sections associated with the incident table with the defined array position. Refer screenshot for further clarifications!!!!!!!
Regards/Neetu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2013 12:57 AM
Awesome.. Thank you so much..
Have a great day 🙂
Wamiq
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2013 12:29 AM
There is a requirement that just hide the content of column of a section...Like in related list of problem,i just want to hide the incident number but its reference icon must be there