The Designer comes with a set of out-of-the-box formulas so you can easily incorporate common calculations or operations into your flow. Formulas are generally used in the following aspects of Interaction design:
- Building Interaction elements: The formula is included in one of the elements of an Interaction page, e.g., in a Question or a Paragraph. In runtime, the formula's placeholder is replaced with the calculated value.
- Defining allocators: The formula is used to change the value of a variable. The relevant formula is selected from the Variables list on the right-hand side of the allocator.
Formula Element Types in the Variables List
Formulas are created from the Variables List, which can be opened from most Page 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 (such as Add Days, Round, etc.). Inputs must be supplied. Keep in mind that the function elements displayed in the Variables list 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. However, if you are designing a paragraph, all the function elements will be listed.
For more details about building functions, refer to Defining Function Elements (below). - Internal Value Elements: Variables that are known to the server. No inputs are needed. Internal value elements are Random number, Current date, and Empty string.
- Arithmetic Calculations: Supported calculations are addition, subtraction, multiplication and division. Supported operations are:
+, -, /, *, %, and ()
You may define calculations in any element featuring an HTML editor (Paragraph, Resource and Email), as well as in any field that supports mixed input of variables and text (such as the label of a question).
To create a calculation, press @ to open the Variables list, and then press the = key. Then, 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 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.
Defining Function Elements
When you select a function element from the Variables list, the required syntax is displayed, but the inputs need to be provided. For example:
The figure below shows the function element with the inputs defined. In this example, the formula adds 14 days to the current date.
The following table summarizes each function, its syntax and output, and required inputs. A formula may contain only one function element. However, internal value elements (Current Date, Empty String, and Random Number) and variable elements may be used as many times as necessary.
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) | String |
DATETOTEXT | Converts a date variable to a desired date syntax. This function can be used to format a date within a system variable (where date formatting is not supported). |
DATETOTEXT(Date,syntax of text) Note: The syntax specified here is the format of the text output. |
String |
DAYSDIFF | Displays the number of days between two given dates. | DAYSDIFF(Date,Date) | Integer |
ROUND | Rounds off a given number to a specified number of decimal points. | ROUND(Number,decimal_places) | Number |
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 |
TRIM | Removes white spaces from a text. | TRIM(Text) | Text |
Comments