Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

how to know the name of a form section

sonita
Giga Guru

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);

    }

   

   

   

}

1 ACCEPTED SOLUTION

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);


    }
}


View solution in original post

10 REPLIES 10

Oh Finally!! Thanks a lot !!!