- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2017 03:26 PM
The requirement is : On the incident form , Closure Information Tab should not show until resolved state is selected. I need to have the name of the section , not the label. In my code I wrote the label , that's why it's not working. my question is how to get the name??
This is my onchange client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var sections = g_form.getSections();
if(newValue=='Resolved')
{
g_form.setSectionDisplay('Closure Information', true);
}
else {
g_form.setSectionDisplay('Closure Information', false);
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 03:05 PM
Did you try changing the value of state..?
Existing script will not work for form loading if you want to run this script even when the form loads then you need to remove isLoading from the if condition
Here is the script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if ( newValue === '') {
return;
}
if(newValue=='6')
{
g_form.setSectionDisplay('closure_information', true);
}
else {
g_form.setSectionDisplay('closure_information', false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2017 09:20 PM
Hi Soni,
Your requirement basically is to show and hide section tab on base of certain conditions. Please find the servicenow guru article on the same below. You can easily find all the necessary information related your query over there. Please reach me for any further assistance.
Show/Hide Form Section by Name - ServiceNow Guru
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 12:44 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 01:56 PM
In else block the value should be set to false.
In your script in both scenarios the value is set to true
g_form.setSectionDisplay('closure_information', false);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 02:58 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 03:05 PM
Did you try changing the value of state..?
Existing script will not work for form loading if you want to run this script even when the form loads then you need to remove isLoading from the if condition
Here is the script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if ( newValue === '') {
return;
}
if(newValue=='6')
{
g_form.setSectionDisplay('closure_information', true);
}
else {
g_form.setSectionDisplay('closure_information', false);
}
}