Getting an onSubmit client side error when trying to change the form view


When trying to change the view on a form, a client side error shows up and does not allow to change the view. The error shows like below :

onSubmit script error: TypeError: g_form.getControl(...) is undefined.


Using g_form.getControl in the onSubmit client script to get a field value that is not present on the form.

For example, if we are using g_form.getControl('number'), the field named 'number' should be present on the form. 


Add the field used in g_form.getControl to the form so that we will be able to get the field value used.