FX DataGuide Expressions
Introduction
Expressions in the FX DataGuide Form Designer tool allow you to customize the flow, calculate variables, or automate the completion of FX DataGuide forms.
Prerequisites
To use the Form Designer, you need to:
Have these user licenses | Have these permissions | Complete these tasks and review these topics before continuing |
---|---|---|
|
|
Getting There
Expressions are part of the FX DataGuide Form Designer tool in the Admin Portal.
Expressions are fields available in a number of options in the Properties Panel, depending on the currently selected form element.
How it Works
You can build expressions to:
-
take responses to questions and calculate new values
-
and change the visibility of questions or pages in the form
-
automate form actions, such as automatically completing a form
Expressions can be built declaratively using the Build fields in the Properties Panel.
Use the Edit option for an Expression to manually write the expression.
Creating an Expression
When creating an Expression, you can build a new expression or edit an existing expression.
Using the Expression Build Tab
When adding a Form Logic Action (called a Trigger in the Logic section of the Form’s Properties Panel), you can use the Expression Builder to create the rule.
The Builder is limited to comparison actions on the responses to questions and adjusts the fields and options depending on the selected action.
For example, if a selected question does not allow a user to make multiple selections, then the "Any of" and "All of" rule options cannot be selected.
Functions
-
Expression functions follow a standard format:
-
functionName
-
( )
Any function, whether or not it accepts parameters, must be followed by an open and close parenthesis
-
,
For functions with parameters, each parameter is separated by a comma
-
Boolean Function Options
-
Examples of expressions where you desire to evaluate whether a condition is true or false.
Expression Description " >= 21"
Returns
true
if the question has a value of 21 or higher"( + + ) > 21 and == ‘yes’"
Use
or
andand
operators, squares and arithmetic operations"!( == ‘yes’ and ( + + ) > 21)"
Use "!" or "not" to change the result on opposite
"notempty"
Returns
true
ifname
has a valueempty
Returns
true
ifname
has no value" = [‘English’, ‘Spanish’]"
Returns
true
, if a user selects these two values in a question where these values are options. Typically used for checkbox question types."contains ‘Spanish’"
Returns
true
, if a user select 'Spanish' in checkbox. The user may or may not select other values in the question.age() >= 21
Returns
true
, if functionage
returns 21 or greater. The functionage
is described below.
Matrix and Panel Questions
-
You can access values within a Panel of questions or a Matrix question type.
-
Use a "." to access child values
-
For matrix questions, use square brackets to indicate the position of the desired value, where the index begins at 0.
For example to access the first value of a matrix, use
{matrix[0].property}
, where property is the desired value to return. -
To access questions nested inside panels, use this format:
{dynamicpanelname[index].questionname}
Function Types
You can use these functions when building an expression:
iif
Format |
|
Result Type |
Any |
Description |
Returns the value specified by |
Example |
|
isContainerReady
Format |
|
Result Type |
Boolean |
Description |
Returns |
Example |
|
isDisplayMode
Format |
|
Result Type |
Boolean |
Description |
Returns true if a survey is in display mode. |
Example |
|
currentDate
Format |
|
Result Type |
Date |
Description |
Returns the current date. |
Example |
|
today
Format |
|
Result Type |
Date |
Description |
Returns the current date or a date calculated using an optional parameter. The parameter specifies the number of days to be added to the current date. For example, "today()" returns the current date 0 hours, 0 minutes, "today(-1) returns yesterday’s date, "today(1)" returns tomorrow’s date, "today(2) returns day after tomorrow date, and so on. |
Example |
|
getDate
Format |
|
Result Type |
Date |
Description |
Returns the specified question’s date value. |
Example |
|
age
Format |
|
Result Type |
Number |
Description |
Compares specified date value to current date and returns an age in years. The passed date value (which is typically taken from the referenced question) should be defined as a valid JavaScript Date. |
Example |
|
diffDays
Format |
|
Result Type |
Number |
Description |
Returns the number of days between two dates. |
Example |
|
sum
Format |
|
Result Type |
Number |
Description |
Returns the sum of the passed arguments. |
Example |
|
max
Format |
|
Result Type |
Number |
Description |
Returns the largest value from a list of the passed arguments. |
Example |
|
min
Format |
|
Result Type |
Number |
Description |
Returns the largest value from a list of the passed arguments. |
Example |
|
avg
Format |
|
Result Type |
Number |
Description |
Returns the average value of the passed arguments. |
Example |
|
sumInArray
Format |
|
Result Type |
Number |
Description |
Returns the sum of values in a array taken from the specified question property (both - the question and its property - are referenced by their names). |
Example |
|
maxInArray
Format |
|
Result Type |
Number |
Description |
Returns the maximum of all values in an array specified by a property (propertyName) of a matrix question (questionName specified as the question name in curly brackets). |
Example |
|
minInArray
Format |
|
Result Type |
Number |
Description |
Returns the minimum of all values in an array referenced by a property (propertyName) of a matrix question (questionName specified as question name in curly brackets). |
Example |
|
avgInArray
Format |
|
Result Type |
Number |
Description |
Returns the average of all values in an array referenced by a property (propertyName) of a matrix question (questionName specified as question name in curly brackets). |
Example |
|
countInArray
Format |
|
Result Type |
Number |
Description |
Returns the total number of items in an array referenced by a property (propertyName) of a matrix question (questionName specified as the question name in curly brackets). |
Example |
|
Recommended Reading
-
FX DataGuide Overview - Learn the basics about FX DataGuide
-
Manage FX DataGuide Forms - Learn the basics of adding and managing Forms and Form Versions
-
Use FX DataGuide Forms - Learn how to input data into FX DataGuide forms
-
FX DataGuide Setup - Learn how to setup FX DataGuide.
-
FX DataGuide Minimum Permissions - Learn about the minimum permissions required to use FX DataGuide.