You can use the functions available within the Custom JavaScript property of a button or field to do calculations, alter attributes, or change values of other fields. Functions such as “formScope.formdata[“InternalVariableName”]” allow you to make use of a value associated with a field within a request or to reference a field to set the value of that field. This can be used to leverage a button to perform actions resulting in transformations of information such as the ability to populate a result to a field from a calculation involving multiple fields.
Custom JavaScript is available on many fields and controls this guide details a specific example on a click action for a button as well as other functions available within the Custom JavaScript library. When using this it isn't to note that it is executing these events as JavaScript and as such requires specific syntax.
This is a Simple example adding the numbers within two fields whose internal names are customNumeric1 and customNumeric2 and setting the resulting sum to customNumeric3 Example - formScope.formdata["customNumeric3"] = formScope.formdata["customNumeric1"] + formScope.formdata["customNumeric2"]; |
This is a more complex example involving conditional "if" statements that checks that the field within the statement has a none zero value followed by an else statement to be executed if it does, both statements multiply fields and sets the result to another field. Example - if(formScope.formdata["customNumeric4"] !== 0) { formScope.formdata["customNumeric3"] = formScope.formdata["customNumeric4"] * formScope.formdata["customNumeric1"]; } else { formScope.formdata["customNumeric3"] = formScope.formdata["customNumeric2"] * formScope.formdata["customNumeric1"]; } |
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
|