Advanced expression editing advanced-expression-editing
About advanced expression editing about-advanced-expression-editing
Editing an expression involves manually entering conditions to form a rule.
This mode allows you to use advanced functions. These functions let you manipulate the values used to carry out specific queries such as manipulating dates, strings, numerical fields, sorting, etc.
It is also possible to use workflows’ events variables when editing expression. For more on this, refer to the Customizing activities with events variables section.
You can edit expressions in order to:
-
Define a query, via the Advanced mode option which is available when a rule is added.
-
Edit an expression in a workflow. For example, to add additional data to an activity.
-
Edit a visibility condition to define how a block in the HTML content editor is displayed. In this case, the expression is edited in JavaScript format and does not offer the use of advanced functions as standard.
Edit an expression edit-an-expression
Advanced expression edition lets you manually define an expression that corresponds specifically to your needs.
Editing expressions can be used in the Audience window while creating an email or in a Query activity while creating a workflow.
-
Access the expression editing window via one of the methods detailed in the About advanced expression editing section. It involves the following elements:
- An input field in which the expression is defined.
- The list of available fields that can be used in the expression and correspond to the targeting dimension of the query (see Targeting dimensions and resources).
- The list of available functions, sorted by category.
-
Edit the expression by entering an expression directly in the corresponding field or by using the lists of available fields and functions.
Double clicking a field or an expression adds it to the expression in which the cursor is placed.
It is possible to use workflows’ events variables to build an expression. For more on this, refer to the Customizing activities with events variables section.
-
Give your rule a specific name if needed. The name entered will appear as the rule name in the query editor workspace.
Editing an expression lets you personalize the Audiences expression to target your population as needed.
Related Topics:
Expression Syntax expression-syntax
Standard syntax standard-syntax
The standard expressions are made up of one or several conditions that respect the following syntax elements:
-
Each condition takes the form of <value1> <comparison operator> <value2> whereby:
- <value1> is a field or a function. For example @created for the date a profile was created or Year(@created) for the year a profile was created.
- <comparison operator> is one of the operators listed in the Comparison operators section. This operator defines the comparison method between <value1> and <value2>.
- <value2> is a field, a function, or a value inputted manually.
note note NOTE The <value1> and <value2> type data must be identical. For example, if <value1> is a date, then <value2> must also be a date. -
If you would like to use several conditions, they can be combined using logical operators.
- AND: two conditions are intersected.
- OR: two conditions are combined.
For example:
Year(@created) = Year(GetDate()) AND Month(@created) = Month(GetDate())
In this example, the profiles whose creation date is in the current month and year are targeted.
JavaScript syntax javascript-syntax
When defining the visibility conditions of a text type block of the HTML content editor, you must use an expression with JavaScript type syntax.
JavaScript expressions are made up of one or multiple conditions, and they use the following syntax elements:
-
Each condition takes the form of <context> <comparison operator> <value2> whereby:
- <context> is a field or a function that allows you to specify the context. For example context.profile.@email for a profile’s email address or context.profile.firstName.length() for the number of characters of a profile’s first name.
- <comparison operator> is one of the operators listed in the Comparison operators section. This operator defines the comparison method between <context> and <value2>.
- <value2> is a field, a function, or a value inputted manually.
note note NOTE The <context> and <value2> type data must be identical. For example, if <context> is a date, then <value2> must also be a date. -
If you would like to use several conditions, they can be combined using logical operators.
- &&: two conditions are intersected.
- ||: two conditions are combined.
For example:
context.profile.age > 21 && context.profile.firstName.length() > 0
In this example, profiles older than 21 years of age and whose first name has been provided (symbolized by the fact that the firstName field contains at least one character).
Comparison operators comparison-operators
For some rules, the query editor lets you chose a value to define your condition.
Conditions must be linked to values by using one of the following operators.