<< Click to Display Table of Contents >> Synchronize tokens with Each Token option |
When using Each token option as Exit mode, users face a common problem: handling more than one active token in parts of the process, where only one should be active.
Bear in mind that all the information entered in an Activity is actually saved in the database (and thus updated in other opened Activities) when the end user clicks on Next, or finishes it. It is important to notice that if an Activity is active and has been updated but it is not finished, all other activities that are opened at the same time will be outdated, until the Activity is finished.
There are various methods to accomplish a successful synchronization of tokens. Some are explained below:
Using a Complex Gateway
You may use a Complex Gateway and an expression to filter each token and decide whether or not to continue with the process. For example, if you want to keep only the last token that reaches a point you can use the following configuration:
1. Add a Gateway to the model.
2. Add a Boolean attribute in your database where you can control when an instance of the multiple Sub-Process has finished.
3. Evaluate the following expression every time a token reaches the gateways, leaving only the last active. This way only the last token will be able to go through the flow, all other tokens will be discarded:
<count(MyCollection)> = <count(MyCollection[Attrib=true])>;
You can customize your filter according to your business needs.
Using an Exclusive Gateway
You may use an Exclusive Gateway and an expression to filter each token and decide whether continue with the process or work through a different path with that process instance. For example, if you want to keep only the last token that reaches a certain point you can use the following configuration:
1. Add an Exclusive Gateway to the model.
2. Add a Boolean attribute in your database where you can control when an instance of the multiple Sub-Process has finished the Sub-Process.
3. Evaluate the following expression every time a token reaches the gateway. When the condition is not met, the token will be directed to the End event. When the last token meets the condition, the regular flow will continue.
<count(MyCollection)> = <count(MyCollection[Attrib=true])>;
You can customize your filter according to your business needs.
Using a Singleton activity
The Singleton property does not make an activity an element of synchronization itself, but might help depending on your business needs. The Singleton controls that only one instance of an Activity is active at a time. When a Singleton is used and an Activity is active (allocated to an end user), all other incoming tokens will be disregarded. When a Singleton is used and an Activity is NOT active, any incoming token will activate it, even if it was activated in the past.
If you are planning to use a singleton activity, bear in mind that when the activity is activated by a token, the tokens trying to start this activity will be terminated. But when the activity is completed and the token continues to the next activity, the other tokens in earlier activities can continue. Hence, this property is not a synchronization tool, but might be useful.
Last Updated 11/7/2024 10:52:41 AM