Using Conditional Expressions
Conditional expressions are used in a business process to determine the next steps that an instance of a process should take. For example, a form may be routed to different individuals for approval depending on the values of fields in the form.
Conditional expressions let you define the conditions that must be met for a particular outflow path to be taken or for a specific priority to be assigned to a task. Conditional expressions are necessary when several potential paths can be followed after a gateway or activity.
When you click in the Conditional Expression text box, the conditional expression builder appears. This allows you to define the condition according to the XPath language. The conditional expression builder translates the information you enter into an XPath statement.
In the conditional expression builder, specify the conditions that must be met for the action to occur. You can create conditional expressions based on:
- Actions taken during a user task. You can specify an action from a previous user task based on its label, such as "Rejected", "Approved", etc.
- Process Variables. In addition to user task actions, you can create conditions based on the process initiator.
- Field values. You can also use a variable from fields.
Example: An expense report form used in your process contains a "Total Amount" currency field, and you assigned a variable called "total" to this field. You want to route the form to a manager if the total amount is greater than $100, so you create a conditional expression that says, "If total (action) is greater than (operator) $100 (value), take this outflow path."
Note: If you have multiple conditions that determine whether a path is taken, you can insert operators (e.g., "and," "or") into your conditional expressions.
By default, conditional expressions are case-sensitive. Once you've created a conditional expression, you can modify it to make the expression case-insensitive.
Making a Conditional Expression Case-insensitive
- Using the conditional expression builder, create a conditional expression that uses the value that should be case-insensitive. The following image shows a match for a single line field to the value "test".
- After building the expression and clicking Insert, the statement for the conditional expression will appear in the text area below the conditional expression builder.
- Edit the statement to fit the following structure: matches(/dataset/attribute_name, "value", "i")
Using Dates in Conditional Expressions
When specifying a date in a conditional expression, you'll need to use the expected date format yyyy-MM-dd (e.g., 2013-12-01).
Converting Strings to Numbers in Conditional Expressions
The values in number and currency fields are automatically treated as numbers when XPath statements are evaluated. If you want the value in a single line field to be evaluated as a number instead of as a string (letters), use the number() function to force the strings to numbers in number variables. For example, if "/dataset/Single_Line" is a string, you can type "/dataset/number(Single_Line)" to force the string to a number.
If you are already using a number, instead of a number variable, be sure to remove quotation marks from the value.
Related Topics