- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2017 02:17 AM
I have a requirement to only show "Closure Information" section when the state is closed. For that i have the following code but when i change state from closed to a different state, the section is still displayed
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var state = g_form.getValue('state');
if(state == "7"){
g_form.setSectionDisplay('closure_information',true);
}
if (state != "7"){
g_form.setSectionDisplay('closure_information',false);
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2017 02:31 AM
And also make sure you dont have any mandatory fields over there. It will not work if you have any
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2017 02:31 AM
And also make sure you dont have any mandatory fields over there. It will not work if you have any
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2025 06:03 PM
if you want to watch it live, on how to hide sections. you view my video here:
You can also read the full article here to give you a picture and a firm understanding of how the g_form object works. [Article] How to Hide a Section in ServiceNow Using Client Script: A Beginner-Friendly Guide