Formula builder

Use the Formula builder to create formulas with calculated and connected values for variables A placeholder that stores changes each time the workflow runs, such as the information entered in a form, or the name of a file. You can also create variables to store information you use in the workflow, such as an email address..

A formula consists of different parts and in this topic, the functions, inline formulas, and variables are distinguished in the following formats:

  • function
  • inline formula
  • variable

Let's look at a simple example on how to calculate a variable value using a formula. You have a leave request form, which has three fields: Name, Start date, and End date. To calculate the total days of leave, you must calculate the number of days between the start date and end date entered in the form. You can create a variable named LengthofLeave and apply the following formula using the dateDiff function:

  • dateDiff(Datetime.TotalDays,Form.Start date,Form.End date)

On your form, you can insert your LengthofLeave variable in a Label control so that the following message displays:

  • You are applying for 10 days of leave.

For step-by-step instructions, see Step-by-step example: Create variables using formulas via Designer tab.

The formula builder can be used:

  • When configuring form controls in the form designer, you can insert inline formulas directly on a field that has the Insert option available.

  • When creating If-Then-Else statements for form rules, you can create and insert variables with applied formulas.

  • When creating form variables in the Variables tab.

Access the Formula builder

Access the Formula builder from the Form designer, Rules, and Variables tabs.

Open the Formula builder from the Designer tab

While designing forms, you can insert inline formulas directly on a field that has the Insert option available.

Note: Click the Insert option to insert form controls and variables with applied formulas. See Insert dialog fields, buttons, and settings for field descriptions.

  1. In the form designer, click the Designer tab.
  2. Click the form control where you want to insert a variable with an applied formula. The form control configuration panel is displayed.
  3. Hover over a field that has + displayed, until +Insert is displayed.
  4. Click Insert.

    The Insert dialog that includes the Formula builder is displayed.

  5. In the Formula field, type the formula.
  6. Note: 
    • As you type the formula, suggestions of possible functions and variables are displayed to select from if required.
    • From the Lookup pane on the right, you can search for Functions and variables to insert to the formula.
    • You can use logical operators such as && (And), || (Or), == (Equal), and != (Not Equal).
    • On the Functions tab, click the name of a function to display its description, format, and an example.

  7. After you create the formula, click Insert. Your new variable is shown as an inline formula and the calculated value becomes the default value.
  8. For example, avg(84,96,150) will insert 110 as the default value.

Open the Formula builder from the Rules tab

When creating If-Then-Else statements, you can create and insert variables with applied formulas.

To access the Formula builder via Rules tab:

  1. In the form designer, click the Rules tab.
  2. Depending on your workflow, click Add form rule or Add submit rule.
  3. Type a Name for your rule.
  4. Enter parameters for the following statements:
    • If
    • Then
    • Else
  5. Click the Insert option that appears on each field when you hover over a field. The Insert dialog appears where you can view the Formula builder and a list of form controls and variables with applied formulas. See Insert dialog fields, buttons, and settings for detailed descriptions of the Insert dialog.
  6. To type a formula do one of the following:
    • Select the Formula tab on the left and type your formula in the Formula field and then click Insert. Your new variable is shown as an inline formula.
    • Select the Form variable tab on the left and then complete the following steps:
      1. Click Add form variable to open the Formula builder.
      2. Type a Name for your variable.
      3. Select a Type.
      4. In the Value field, type your formulas.
      5. Click Create & insert.

      Your new variable with applied formula is now included in the If-Then statement.

      For example, you can create a rule to check that the age entered matches with the age calculated based on birthday. If true, the form can be submitted. Else, a warning message appears.

Note: 
  • As you type the formula, suggestions of possible functions and variables are displayed to select from if required.
  • From the Lookup pane on the right, you can search for Functions and variables to insert to the formula.
  • You can use logical operators such as && (And), || (Or), == (Equal), and != (Not Equal).
  • On the Functions tab, click the name of a function to display its description, format, and an example.

Open the Formula builder from the Variables tab

  1. In the form designer, click the Variables tab.

  2. Click Add form variable. The Add form variable section is displayed with the Formula builder.

For more information, see Variables