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.
Using expressions
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'"
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.
It is not possible to use the default flow logic. However, you can set one path with the expression 1==1 which means that this will always be true and therefore acts as a default option.
How to add expressions on gateways
- Open the settings for the sequence flow you want to add an expression on.
- In the Expressions section, click on Set and a new window will open.
- Enter the expression for when that expression will be true.
Available expressions
To add expressions based on form data you will need:
- DataID - This is found under the option Data Object Settings like in the example picture.
- fieldName - This is used in the expression to validate true or false and represents the input value in the field.
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:
-
Equal: ==
-
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: ||
Prefixes:
-
Check if a multi selection includes a value: .include?
-
Convert to integer for mathematical expressions: .to_i
Quotations around your values indicates a string (text) and no quotations indicates a number (integer).
Example syntax
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:
instance.GetDataObject("DataID")["fieldName"].include? "Value"
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"
All expressions check the actual value the fields have, checkboxes default to "on" / "off"
If you add inputValue as an attribute on the checkbox field, then it will change the "on" value to whatever was specified in the attribute.
If you want to check if an attachment field is used:
instance.GetDataObject("DataID").ContainsKey('fieldName')
&& (instance.GetDataObject("DataID")['fieldName'].include? ".")
If you want to check against a value from a metadata 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 on the gateway and click the Use end state from process. Choose which process you wish to draw your end state from. Do not forget to name your subprocess or call activity.
- Draw your connector paths out from the gateway and double click them and select Choose end state for this sequence flow. Choose which end state you want to trigger each sequence flow.
Now you have configured a gateway using the subprocess end state.
Comments
0 comments
Article is closed for comments.