Hide form section based on field is empty.

Kruthik M Shiva
Tera Contributor

Hi All,
I have a requirement like hiding form section based on one of the fields is empty. I have created on load client script, but it is not working anyone help me on this what is the issue, and anything need to be changed in my script.
PFB script I used in clientscript.

function onLoad() {
   //Type appropriate comment here, and begin script below
var iav1=g_form.getValue('iav');
var mv=g_form.getValue('module_name');
 
 
if (iav1==' ')
{
 
    g_form.setVisible('iav_ipod', false);
 
}
 
 if (mv==' '){
 
    g_form.setVisible('mv_ipod', false);
 
}
}
6 REPLIES 6

Ahmmed Ali
Mega Sage

Hello @Kruthik M Shiva 

 

Do you want to show/hide section on the form or just fields on the form? in your script you are hiding the fields.

 

If it is the fields, you can simply create one UI policy with required condition and set field visibility to false.

 

If you want to hide section display, then you will need to use g_form.setSectionDisplay() function. To know your section name, you can write below alert message in your onload script alert(g_form.getSectionNames());

 

Thank you,

Ali

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Kruthik M Shiva
Tera Contributor

Hi @Ahmmed Ali ,
I tried it's not working; can you please tell what needs to be changed in my script.

@Kruthik M Shiva 

 

What is the field/s name and what is the section name?

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Harish KM
Kilo Patron
Kilo Patron

Hi you need to use below method to hide section. If there are any mandatory fields not filled, section will not hide

 

 g_form.setSectionDisplay('notes', false);//notes is the section name ,
function onLoad() {
//Type appropriate comment here, and begin script below
var iav1=g_form.getValue('iav');
var mv=g_form.getValue('module_name');
if (iav1==' ')
{
g_form.setSectionDisplay('iav_ipod', false);


}

if (mv==' '){

g_form.setSectionDisplay('iav_ipod', false);

}
Regards
Harish