Calculation Field
Introduction
The Calculation Field allows you to perform a series of arithmetic computations on a set or a series of fields. This feature is available only in Joget's Enterprise Edition.
How does it work?
The easiest way to see how the Calculation Field works is to use the existing built-in App Expenses Claims and look at an existing form. Follow these steps:
- Start the Joget Server and open the App Center.
- Log in as admin and click the pencil icon on the Expenses Claim to open the Design App.
- Under the Form Builder column, click on Expense Claim Form.
- Click on the Calculation Field labeled Total Amount $ on the canvas to open up the Configure Calculation Field properties.
- Take note of the Variables field. The
spECD
value refers to another field within the form. - Click the Grid element to open the Edit Grid properties.
You are summing a specific column from a Form Grid. - Click Preview and enter values into the Amount column in the Grid to see the Total Amount $, and automatically add the values.
Configure calculation field
Configuring the Calculation Field involves setting various properties to define how the field behaves and interacts with other fields.
Fields to configure:
- Label: Element label to be displayed to the end-user.
- ID: Element ID. A corresponding database table column c_total will be created by declaring it as total. See Form Element for more information about defining the ID and a list of reserved IDs.
- Variables:
-
-
Variable Name: Declare a name to store the current row equation result.
For Example:- subtotal
- discountPercent
- charges
- Field ID: Form Field ID to retrieve.
If you are totaling a form grid column, use this format:formGridId.columnId
where the first part before the decimal tells Joget which form grid to use, and the second part after the decimal tells Joget which column in the specified form grid to use for calculation. -
Multivalue Operation:
- Sum
- Avg
- Min
- Max
-
-
Equation: Arithmetic operation using the variables declared above.
For example:
- subtotal - (subtotal * discountPercent / 100)
- subtotal - discountAmount
- subtotal - charges (Correct)
- subtotal-charges (Wrong)
Advanced Options
These options provide additional customization and validation features for the Calculation Field.
Data & Validation
This section allows you to attach validators and configure data-related properties.
Field to configure:
- Validator: Attach a Form Validator plugin to validate the input value. Validation takes place whenever a form is submitted except when it is submitted as Save as Draft.
Format
Here, you can define the display and formatting options for the calculated value.
- Formatting Style:
- US Style Formatting (1,000.00)
- European Formatting (1.000,00)
- Number of Decimal: Number of decimals.
- Prefix: The prefix of the calculated value.
- Postfix: Postfix of the calculated value.
- Use Thousand Separator?: Thousand separator toggle.
- Store as Numeric Value?: Toggle to store as a numeric value instead of a string.
UI
This section deals with the visibility and display options of the Calculation Field.
Fields to configure:
- Hidden?: Show or hide this element to the end user.
- Display as Label?: Display the value of the element as plain text.
Workflow
Configure workflow-related properties for the Calculation Field to integrate with workflow processes.
Field to configure:
- Workflow Variable: If the form is part of a workflow process, upon saving the form by clicking the Save as Draft or Save button, the value in this input field will be saved into the corresponding workflow variable named in this field.