We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Field present on form

Lohith
Giga Expert

Hi Team,

How to know whether a field exists on form or not

For ex: I want to know whether field A present on form or not, if present then go ahead and perform validations. if field not exists on form then

don't perform any validations.

Appreciate your inputs

Thanks,

Lohith

1 ACCEPTED SOLUTION

Shishir Srivast
Mega Sage

you can check using g_form.hasField('<your field name>') if field is present on the form or not.


View solution in original post

6 REPLIES 6

Please find the Sample code below on incident form.



function onLoad() {


  if(g_form.hasField('caller_id'))


  {


  alert('true');


  }


else


  {


  alert('false');


  }


}


Venkateswarlu K
Mega Guru

Hi Lohith can u pls follow this images



find_real_file.png


After that


find_real_file.png


here you will get   the all fields on the form.I hope this will helpful to u