Computing fields using Formula Builder
- What is Formula builder?
- Writing formula using the Formula builder
- How to use the editor in the Formula builder effectively?
You can write expressions and create formulae for your computed fields with the help of our all-new 'Formula builder'.
What is Formula builder?
The Formula builder is an inbuilt tool in Kissflow that helps you write, edit, and evaluate expressions much effectively.
Highlights of the feature
- Easy-to-use editor
- Auto-suggest options while using the dot operator "." and calling functions
- Simple drag-and-drop design to include fields and functions on the editor
- Ability to evaluate your expression before saving it
- Handy Search interface to look out for a field or a function
Writing formula using the Formula builder
- Navigate to the field in your process form for which you would like to write a formula.
- Toggle the 'Is this a computed field?' field to 'Yes' to enable it.
- Scroll down and click the Expand icon to access the Formula builder.
- Type the logic in the editor.
- You might require a field and a relevant function to build a formula. We support system fields and your form fields in the editor so that you can use any of them in your logic as necessary. We also have a specific set of functions that can be easily dragged and dropped onto the editor.
- Drag and drop a relevant function from the Functions section from your right-hand panel.
- A function operates on one or more fields so navigate to the System or Form fields section to look out for the relevant fields and build your formula.
- Drag and drop or double-click the relevant field from the System fields or Form fields section onto your function in the editor
- Click Beautify to format your code when you are done with its logic.
- Click Evaluate to test your formula before saving it.
- Enter the required input to the fields and click Run to evaluate your expression.
- Click Save after your expression is evaluated successfully.
How to use the editor in the Formula builder effectively?
The editor has an intuitive interface that lets you build your formula within seconds. The following tips might come in handy when you write your logic:
Using dot operator
You can use the Dot operator "." to insert inbuilt functions into your logic. You can choose a relevant function from the auto-suggest panel that shows up while you use a dot operator in your expression.
Calling inbuilt functions
We support the following functions in the editor and you can drag and drop any of them onto your editor as necessary.
Number and Currency:
There could be instances where you have to generate a random number or execute currency-related calculations in your formula. Learn more on the Number and Currency expressions here.
Perform operations on strings using the list of text-related functions that Kissflow supports. Learn more on the Text expressions here.
Display current date with or without current timestamp, fetch the current day or the timestamp when an item was initiated as per your requirements using our date functions. Learn more on the Date expressions here.
Other logical expressions:
We also supported a few logical functions in our editor. For example, you can check if a specific field is empty or not using the isBlank() function. Learn more on the Logical expressions here.
Formatting your code
Are you worried about the cluttery look of your code on your editor when you try your hands on a complicated formula? We heard you!
Click Beautify in the upper-right section of your Formula builder to format your code so that your logic is intended and neatly presented in the editor. Formatting not only gives a facelift to your code but also improves its readability.
Copy, Undo, and Redo
You can copy the code to your clipboard, or undo/redo the changes as necessary from your editor. Access the Formula builder and go to the upper-right part of the editor to access these options.
Using arithmetic and logical operators
We support all the basic arithmetic and logical operators which are necessary to build a formula. Click any operator to insert them into your code as necessary.
Hover over an operator to learn about its usage.
It's a recommended practice to evaluate your formula before executing it in your process. It helps you test the formula and check if you get the desired output.
- Click Evaluate when you are good to test your logic.
- Give your inputs for the fields under the Evaluate formula section in your right-hand panel.
- Click Run
- View the output of your expression at the bottom and retest the formula as many times as you want until you achieve the desired results.
Referring to the contextual help
When you are not sure about how to use a specific function, hover over its name to learn about its usage. You can also do the same to fix syntax errors if any while evaluating your expression.
In the following example, there is a syntax error in the expression. The output of the function 'randbetween()' must be TEXT whereas its current datatype is NUMBER. Let's see how the issue is resolved with the help of the contextual help options available in the editor.
Stages of the fix:
- The intuitive design of the editor alerts the user that there is an issue with the logic. (Run disabled)
- The user hovers over the syntax to learn what went wrong.
- The user learns that the randbetween() function must be converted to TEXT as its current datatype is NUMBER.
- The user calls the totext() function using the Dot operator to get the output as a string.
- Error is resolved and the expression gets evaluated successfully.