Skip to main content

Uniphore Customer Portal

Using Formulas in Your Flow

X‑Platform provides a set of out-of-the-box formulas that you can use in common calculations or operations when designing a Flow.

Formulas are especially useful in the following ways:

  • Building Flow Elements: The formula is included in one of the elements of Flow (e.g., a Question or Paragraph). During runtime, the formula's placeholder is replaced with the calculated value.

  • Defining Allocators: The formula is used to change the value of a variable. You can select the relevant formula from the Variables list on the right-hand side of the Allocator.

  • Building Rules: The formula is used to help calculate a Rule for testing a logical condition during runtime.

Formula Element Types in the Variables List

Formulas are created from the Variables List, accessed in most element editors by entering '@' in the relevant field. The following element types and features related to formulas are available in the Variables list:

  • Function Elements: Predefined functions (e.g., Add Days, Round, Text to Number, etc.) that perform useful calculations or conversions on data elements you specify. The data inputs must be supplied.

    VariableFunctionElement_061221.png

    A function is indicated by the VariableFunction_icon.png icon found to the right of its name. For more details about building functions, click here.

    Note

    Keep in mind that the functions available in the Variables list will change according to the context in which you are working. For example, if you are modifying the value of a date variable, only formulas related to dates will appear.

  • Internal Value Elements: Variables that are always known to the X‑Platform Server. No inputs are needed. The internal value elements available are:

    • Random Number

    • Current Date

    • Empty String

    VariableInternalValueElement_061221.png

    An internal value element is indicated by the VariableInternalValue_icon.png icon found to the right of its name. Internal value elements can be used as many times as needed in a formula.

  • Arithmetic Calculations: Supported calculations are addition, subtraction, multiplication and division. Operations supported are: +, -, /, *, %, and ().

    You may use calculations in any element featuring an HTML editor (e.g., Paragraph or Email), as well as in any field that supports mixed input of variables and text (e.g., the label for a Question element).

    To create a calculation, enter '@' to open the Variables list, and enter the = key. In the gray field that appears, enter your calculation. To use a variable in your calculation, enter '@' to open the Variables list and select the required variable. To define a new variable, at the top of the Variables list, click the Plus VariableEditorAddVar_icon.png icon to open the Variable Editor.

    In the following example, the value provided in an input question is multiplied by a constant, to calculate the charge to the customer.

    Formula-CalculationExample_061221.png
Defining Function Elements

You add a function in-line just as you would add a Variable, by entering '@' in the element. When the Variables list appears, you select the desired function.

With the Variables list open, you can enter a few letters of the function to locate it quickly, as shown below:

Formulas-FunctionTooltipDisplay_261021.png

Select a function to insert it in-line at the cursor. The function will be added without any inputs. To see which inputs you need to supply for a selected function, hover over the InfoVariableInfo_icon.png icon located at the right side of the function.

Below is a sample function with its inputs defined:

Formula-ADDDAYSExample_062121.png

This formula calculates a delivery date using the ADDDAYS function to add 14 days to the current date.

Available Functions

The following table lists each function, its syntax and required inputs, and its output. Each formula you create can contain only a single function element.

Function

Description/Notes

Inputs and Syntax

Output

ADDDAYS

Adds a specified number of days to a given date.

ADDDAYS(Date, Number)

Date

ADDMONTH

Adds a specified number of months to a given date.

ADDMONTH(Date, Number)

Date

CONCATENATE

Joins two texts.

CONCATENATE(Text1, Text2)

Text

DATETOTEXT

Converts a date variable to a desired date syntax.

This function can be used to format a date within a Session Variable (where date formatting is not supported).

DATETOTEXT(Date, Syntax of text)

Note

The syntax specified here is the format of the text output.

Text

DAYSDIFF

Displays the number of days between two given dates.

DAYSDIFF(Date, Date)

Number

NUMBERTOTEXT

Converts a number value into a string, and provides a mechanism for preserving the portion expressed in decimal places.

NUMBERTOTEXT(Number, Number of decimal places to convert)

Text

ROUND

Rounds off a given number to a specified number of decimal points.

ROUND(Number, Decimal places)

Number

TEXTCOMPARETOBOOLEAN

Compares two text values and returns the Boolean True if they are equal. This function is useful for evaluating whether a custom string (being used in place of the standard Boolean True/False values) equals True.

TEXTCOMPARETOBOOLEAN(Text value, Text string that returns true)

Boolean

TEXTTOBOOLEAN

Converts a text string into a Boolean value. True (or 1) will produce the value Yes, and False (or 0) will produce the value No.

To customize the text that is examined to produce the Boolean value, use the function TEXTCOMPARETOBOOLEAN.

TEXTTOBOOLEAN(Text)

Boolean

TEXTTODATE

Converts a string into a date variable according to a specified format.

This function is generally used to convert a text variable (e.g., an input question response, an Integration Point response, etc.) into a date variable. Additional functions (e.g., ADDDAYS), can then be performed on the date variable.

TEXTTODATE(Text, Syntax of text)

Note

The syntax specified here is the current format of the text input.

Date

TEXTTONUMBER

Converts a text string into a number value.

TEXTTONUMBER(Text)

Number

TRIM

Removes white spaces from a text.

TRIM(Text)

Text