Best method to determine if a field is displayed on a form

Patrick Logan
Tera Contributor

Hey all, 


I'm looking for the best method for a Client Script to determine if a field is visible on a form. Searching around, I found the following but it doesn't seem to work.  The field I'm cocerned with is "support_by" and I'm using the comments field just to determine the result of the if statement. 

if (g_form.isVisible('supported_by')) {
    g_form.setValue("comments","Visible");
} else {
   g_form.setValue("comments","Not Visible");
}

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Hi @Patrick Logan 

the correct method for your use case is:

g_form.isFieldVisible('FIELD NAME');

Maik

View solution in original post

3 REPLIES 3

Maik Skoddow
Tera Patron
Tera Patron

Hi @Patrick Logan 

the correct method for your use case is:

g_form.isFieldVisible('FIELD NAME');

Maik

Excellent. Thank you.

shubhamdubey
Mega Sage

@Patrick Logan 

 

Hi kindly check this code

 

function onLoad() {
   //Type appropriate comment here, and begin script below

   var visibleField = g_form.isFieldVisible('short_description');

   if(visibleField == true){
    g_form.setValue('description' , "field is visible");
   }else{
    g_form.setValue('description' , "field is not visible");
   }
   
}