Expressions can be used to create or change an object or a variable based on logic.
The Expression tab is opened when you configure the following activities in the microflow:
For more information, see Setting and Changing a Value for Different Activities in the Microflows in the Web Modeler.
2 Writing the Expression
There are two ways of writing an expression:
- Using suggestions
- Writing the expression manually
If some errors appear in the expression, hints with an explanation will be displayed.
2.1 Writing the Expression Using Suggestions
To write an expression using suggestions, do the following:
- Browse through the list of suggestions and select the element for your expression with a mouse or a keyboard.
- To add more elements to the expression, press Space.
- Select the element from the list.
- Click Add when the expression is completed.
The list of suggestions is adjusted depending on the previous elements in the expression.
To call the list of suggestions, press Ctrl + Space
2.2 Writing the Expression Manually
If you want to write the expression manually, pay attention to the following:
- Variables in the microflow can be called in an expression by inserting the dollar sign followed by the name of the variable. For example, $Customer refers to the variable Customer
- Attributes and associations of object variables are accessed using a slash, for example, $Customer/Name, $Customer/Grade refer to the attributes Name and Grade of the entity Customer
- Unary, boolean, and relational types of expressions are available in the Web Modeler (for more information, see section 3 Expression Types)
2.3 Examples of the Expression
Let us study two examples that illustrate how the expression can be used.
2.3.1 Example 1
You have an exclusive split and you want to write an expression that checks whether the customer grade is gold and the price of the order is more than 100 (you can configure a discount after the split that is allowed if this expression is true).
The expression will look the following way:
2.3.2 Example 2
A common example is when you first check if the object (in our example the object is Customer) exists. And then you check if the Customer’s name matches a particular one (in our example Customer’s name is Mendix). The expression will look the following way:
3 Expression Types
An overview of the possibilities with expressions can be found below:
3.1 Relational Expressions
- Less than ( < )
- Greater than ( > )
- Less than or equal to ( <= )
- Greater than or equal to ( >= )
- Is equal to ( = )
- Is not equal to ( != )