Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Show/hide section with onChange client script

joaosantos
Mega Expert

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

}

   

}

1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron

And also make sure you dont have any mandatory fields over there. It will not work if you have any


Regards
Harish

View solution in original post

6 REPLIES 6

Harish KM
Kilo Patron
Kilo Patron

Comment this code or remove isLoading and check



  if (isLoading || newValue === '') {


          return;


    }


Regards
Harish

Mujtaba Amin Bh
Mega Guru

Try this,



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


}


else{


g_form.setSectionDisplay('closure_information',false);


}



}


vinothkumar
Tera Guru

Hello Jao,



Try modifying the code as below



function onChange(control, oldValue, newValue, isLoading, isTemplate) {



if(newValue!= oldValue && newValue != '')


{


    var state = g_form.getValue('state');


          if(state == "7"){


                  g_form.setSectionDisplay('closure_information',true);


}


else{


        g_form.setSectionDisplay('closure_information',false);


}


}


}