TABLE OF CONTENTS
- Using expressions
- How to add expressions on gateways
- Available expressions
- Operators & Prefixes
- Example syntax
- Finding expression errors
- When to use expressions on Gateways
- Use Subprocess End State to Configure Gateways
Use expressions on your gateways to automatically choose which way a process should go depending on the information in forms or instances. Expressions can be used on both inclusive and exclusive gateways.
Expressions are not added to the gateway itself, instead, they are configured on the sequence flow(s) that are connected from the gateway. The best practice for labeling gateways and sequence flows is to name gateways with a question, and name each outgoing sequence flow as an answer to the question. This makes it easy to understand what the choice is and which way the process will continue depending on the answer. The process will continue along the expression(s) that are true.
Expressions are written using a special syntax. Each expression must result in a true or false result. For example:
"The value of this field in this form is equal to 'Computer'"
"The number in this field in this form is greater than 100"
It is possible to combine multiple questions. However, both questions must be true for the entire expression to be evaluated as true.
"The value in this field is equal to 'red' and the value of that field is equal to 'blue'"
For an exclusive gateway, the process will continue in only one way as it will exclude all other options that are not validated as true. This is why default flow is the recommended option to avoid the process getting stuck on an error, it means that no validation of true is needed for the flow to continue on the default path.
Note: If you configure expressions on an exclusive gateway, make sure to configure all paths either with a valid expression and/or default flows. Otherwise, the process might get stuck or pick an unpredicted path.
For an inclusive gateway the process will continue in all the paths that are validated as true. This means that the inclusive gateway includes more than one option in caparison with the exclusive gateway. The inclusive gateway is a combination of a parallel and an exclusive gateway, meaning that it can choose multiple paths.
Note: It is not possible to use the default flow logic. However, you can set one path the with expression 1==1 which means that this will always be true and therefore acts as a default option.
How to add expressions on gateways
1. Open the settings for the sequence flow you wish to add an expression on.
2. In the section Expressions, Click on Set and a new window will open.
3. Enter your expression for when that expression will be true.
To add expressions based on form data you need to locate the DataID. This is found under the option “Data Object Settings” like in the example picture.
The second thing you will need is the fieldName, this is used in the expression to validate true or false and represents the input value in the field.
Note: If you want to use data from a form template, the DataID of the template can not include spaces. The combination of the dataID and the fieldname is written in the expression syntax like this: instance.GetDataObject("DataID["fieldName"] OPERATOR/PREFIX "Value to check against"
Operators & Prefixes
Operators for mathematical expressions:
Not equal: !=
More than: >
Less than: <
More than or equal: >=
Less than or equal: <=
Operators for combinations of more than one expression:
And - All expressions must be true: &&
Or - At least one expression must be true: ||
Check if a multi selection includes a value: .include?
Convert to integer for mathematical expressions: .to_i
Note: Quotations around your values indicates a string (text) and no quotations indicates a number (integer).
If a field value is equal to something specific:
instance.GetDataObject("DataID")["fieldName"] == "Computer"
If a field value is less than or equal to something specific, but numeric value:
instance.GetDataObject("DataID")["fieldName"].to_i <= 100
If a certain value of a drop-down, with multi selection, is selected:
Note: If you have a single selection drop-down, then the syntax is the same as a field value equal to something specific.
If a checkbox is selected:
instance.GetDataObject("DataID")["fieldName"] == "on"
If a field value is equal to something specific AND a checkbox is selected:
instance.GetDataObject("DataID")["fieldName"] == "Computer" && instance.GetDataObject("DataID")["fieldName"] == "on"
If you want to check if an attachment field is used:
instance.GetDataObject("DataID").ContainsKey('fieldName') && (instance.GetDataObject("DataID")['fieldName'].include? ".")
Note: If you want to check against a value from a metadeta field and you have a value list with key values, the Value to check against must be your key value.
Finding expression errors
Expressions can be complex, and small details in the expression may be the difference of your expression working correctly or not. If an expression does not run the way you expected it to, you can check the process application Event Log for any errors that your process application encountered. This information may be a little technical, but it gives you a good indication of what went wrong. If you need additional help solving your expression problem, do not hesitate to contact our support team and supply them with the error code.
When to use expressions on Gateways
Expressions on gateways can be used to evaluate form data and choose different process paths. Depending on the form input, expressions can automate decision making and streamline the process.
Use Subprocess End State to Configure Gateways
This function allows you to configure which path a gateway will direct the workflow based on which end state a previous sub process or call activity had, without writing an expression.
Every completed instance or sub instance has an end state matching the name of the end event that caused the instance to complete. These end states are selectable as options for configuring which way an inclusive or exclusive gateway will take after a sub process or call activity has been completed.
Here is how to configure it:
Add an inclusive or exclusive gateway following your desired Subprocess or Call activity in your process model.Add two or more possible end events for the Subprocess/Call activity and name them.
Double click the gateway and click the Use end state from process. Choose which process you wish to draw your end state from and do not forget to name your subprocess or call activity.
Draw your connector paths out from the gateway and double click them and click Chose end state for this sequence flow. Choose which end state you want to trigger each sequence flow.
Now you have effectively used the subprocess end state to configure a gateway!