Vinayak Belgaon
Mega Guru
Mega Guru

Client Script API

When you do a g_form.getValue() on a checkbox type of field it will return a string type of value(true/false, typeof string). Instead use the getBooleanValue() for field with type as checkbox.

 

function onSubmit() {
   var fieldChecked = g_form.getValue('field_name');
   console.log(typeof fieldChecked); //String

   var isChecked = g_form.getBooleanValue('field_name');
   console.log(typeof isChecked  );//Boolean
}

 

For nerds below if the actual definitions of the function

g_form.getBooleanValue(fieldName)
ƒ (fieldName) {
var val = this.getValue(fieldName);
val = val ? val + '' : val;
if (!val || val.length == 0 || val =="false")
return false;
return true;
}



Returns false if the field's value is false or undefined, otherwise true
is returned. Useful with checkbox fields Returns true when the checkbox is checked

Click here for Official Documentation :

Version history
Last update:
‎08-04-2022 03:23 AM
Updated by: