Articles on: Process Form
This article is also available in:

Auto calculated type field

With Flokzu's auto-calculated fields, you can get values automatically, saving time and preventing errors!

Imagine you're creating a form for your purchase orders. You could have a table with items, quantity, and unit price. A "Total" column would let you calculate the amount for each item (quantity x price). Plus, you could include an auto-calculated Purchase Total field that sums all those totals automatically.
This means that when completing a task, your users won't be able to modify the value of an auto-calculated field, as Flokzu will generate it for them automatically and dynamically.

How to Create an Auto-Calculated Field



Creating an auto-calculated field is very straightforward:
Add a new field to your form.
Select the "Calculated" data type.
Click on "Click to edit Calculated Field..."




Once you're in, you can choose the function you want to apply and the fields involved in the calculation. These are the fields from your form that Flokzu will use to get the final value. Remember, you need to have added these fields to your form before configuring them in the auto-calculated field!

The available functions are:

Sum: To add values.
Max: To get the maximum value.
Min: To get the minimum value.
Count: To count elements.
Mult: To multiply values.
Script: If you need more advanced calculation logic.
You can also choose the "$" mask if you want the currency symbol to show in your auto-calculated field.



Keep in mind that the Sum function is very versatile. You can sum text fields (single or multiple lines), whole numbers, decimal numbers, combos (dropdown lists), columns from other tables, and even other auto-calculated fields!

Example: Given the table columns: Item, Unitary Price, Quantity and Total Price, we cam calculate first the values under Total Price. In order to do this, you must multiply "Unitary Price" by "Quantity" as shown in the following image:



Once you have done this, you can sum the values under this column in a calculated field called "Total purchase".



Data Types and Formats for Your Calculations



For your calculations to work perfectly, we recommend that the fields you use in an auto-calculated field are always numeric. Flokzu will correctly interpret the values, regardless of whether they have thousands or decimal separators configured.

If you use a text field to enter a numeric value, Flokzu will assume that the period (.) is the decimal separator and that the value has no thousands separators.

Important! If a user enters non-numeric values in any of the fields involved in the calculation, Flokzu will interpret them as zero (0) for the function. If the result of the operation is invalid, the value displayed in the auto-calculated field will also be zero (0).


Visibility of an Auto-Calculated Field



Auto-calculated fields can have four types of visibility, allowing you to control how they behave in your form:

Hidden: The field isn't shown on the form.
Inactive: The value of the auto-calculated field doesn't update, even if the fields that feed it change. This is useful for "freezing" a value at a specific moment.
Active: The field's value is calculated in real time whenever any of the involved fields change.
Required: The field is active and must have a value before the task can be completed.



Keep in mind that an auto-calculated field always performs its calculations based on the involved fields that are visible. If the function uses a field that is hidden, that field will sum up as zero (0), even if you had previously assigned a value to it.

Just like with other fields in your form, you can use the value of an auto-calculated field to set conditions in your workflow or even insert its value into an automatically sent message (for example, in a Send Task).

Scripts in Auto-Calculated Fields: Advanced Logic



If you need more complex calculation logic than the predefined functions, you can use scripts in your auto-calculated fields. Here are some important guidelines:

To refer to your form fields within the script, use the Mustache format, enclosing the field name in double curly braces, like this: {{Field Name}}. For example: {{Number of units}}.
We recommend that the script be concise and contain only the necessary logic. For example: {{Quantity}} * {{Unit price}}.
If the logic is very complex, you can define it within a function for better organization. For example:

myFunction
(); 
                 function myFunction() { 
                 ... your complex logic here ... 
                 }



To develop these scripts, the same recommendations apply as for script development in Flokzu in general. It's important to use functions like parseInt or parseFloat when performing mathematical operations, and you can also use libraries for date handling. Additionally, within the script, you have access to Flokzu's own functions like getFieldValue().

Important! It's not possible to use the onChange and onInit functions within the scripts of auto-calculated fields. They will have no effect and can cause unexpected behavior.

Updated on: 24/06/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!