How do I create a Calculated Field?

Description

Calculated fields in a Form Design are defined using TPL.

To create a calculated field, you must add TPL to the ON *CHANGED event for the field(s) to compute the new value and save it in the field.

  1. Open the TPL Editor for the form that contains the calculated field. Go to Advanced Features > Edit Custom Code.

    /TransFormDocumentation/pages/images/openTPLEditor.png

    Select the Yes radio button above the Edit Custom Code link to enable the TPL editor.

  2. Next, click the Changed button for the field that is used to compute the value.

    /TransFormDocumentation/pages/images/editOnChanged.png
  3. Enter TPL in the ON *CHANGED function to compute the value and set it in the field:

    ON *changed_length
    
        #area = #length * #width
    
    ENDON
    Field names are case sensitive!
  4. Click Save to save your calculation.

    /TransFormDocumentation/pages/images/saveCode.png
  5. If the calculated field is computed from multiple controls, repeat the above steps for each field.

    /TransFormDocumentation/pages/images/calculateArea.png
    The 'area' computation is added to the ON *CHANGED event for both the 'length' and 'width' fields
  6. After you have added the TPL to the ON *CHANGED field(s) to update the calculated field, click Save on the left-hand side of the screen to save your changes. Then, click Click to save changes to upload your changes to the TransForm Cloud.

    /TransFormDocumentation/pages/images/saveAllTPLCode.png
    Save changes to the Form Design
    /TransFormDocumentation/pages/images/saveFormChanges.png
    Save changes to the TransForm Cloud, making them available in the TransForm Filler App
  7. Finally, test your form in the TransForm Filler mobile application.

    /TransFormDocumentation/pages/images/calculatedField.png

See Also