how to check if the variable is present on the form or not using client script?

GD11
Tera Expert

g_form.hasField() and g_form.isVisible is not working, please advise.

4 REPLIES 4

Kieran Anson
Kilo Patron

If you're in the Core UI, you would need to use g_form.isFieldVisible('field_name_here'), for service portal g_form.isVisible will work 

This was the solution for me, thanks!

Anand Kumar P
Giga Patron
Giga Patron

Hi @GD11 ,

Use the g_form.getControl(fieldName) method. This method returns the HTML element for the specified field. If the field does not exist on the form, it returns null.

function onLoad() {
var name = g_form.getControl('u_application_name');
  if(name !== null)
name.placeholder = "Common name for the application";
    }

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

Anurag Tripathi
Mega Patron
Mega Patron

This is another function that works

  alert(g_form.hasField('<variable name>'));
-Anurag