cancel
Showing results for 
Search instead for 
Did you mean: 

Changing business key after process start

kaech
Champ in-the-making
Champ in-the-making
Hi,

I want to implement correlation with an external system and the businesskey (orderid) is generated as part of the process and not upfront.
Is it possible to change the business key after the process has been started?
3 REPLIES 3

frederikherema1
Star Contributor
Star Contributor
BEWARE: non-API advice: The only way to do this, is to cast the DelegateExecution to a ExecutionEntity and call setBusinessKey(..) on it. This should be done IN activiti-context, best in the step that actually calculates/fetches the business key -> so in a JavaDelegate.execute() or a task/execution-listener.

Again, this is not a public API. Also, errors can occur (database-constraints exception) when setting the business-key to a value that is already present in the runtime/history process-instances.

kaech
Champ in-the-making
Champ in-the-making
Thank you for the information.

Are there any plans to change this behaviour?
To me it seems very common that the business key can not determined before the process starts.
I would also be nice to support multiple business keys to support scenarios in which several systems have to be integrated using different keys for correlation.

frederikherema1
Star Contributor
Star Contributor
Looks like you'll have to revert to the process-variables for that. You can easily correlate based on those values, e.g.:


// Get process-instancer associated to order in SystemABC
runtimeService.createProcessInstanceQuery().variableValueEquals("orderNumberFromSystemABC","ORD-22598125").singeResult();