moshell
September 15, 2023, 12:39pm
1
Hello!
camunda runtime service has method
ActivityInstance activityInstance = camunda.getRuntimeService().getActivityInstance(instanceId);
in debug mode i see activityInstance has businessKey field
but there is no method for retrieve it.
how can I get businessKey without rest api?
Hello my friend!
Welcome to Camunda Fórum!
BK is related to processInstances directly…
So first you must search for the processInstanceId that you want the businessKey, and then search for the BK value, as I did below.
var processInstance = execution.getProcessEngineServices().getRuntimeService()
.createProcessInstanceQuery()
.processInstanceId(execution.getProcessInstanceId())
.singleResult();
var businessKey = processInstance.getBusinessKey();
I hope this helps!
William Robert Alves
2 Likes
You can do it this way if you want to simplify:
var businessKey = execution.getProcessEngineServices().getRuntimeService()
.createProcessInstanceQuery()
.processInstanceId(execution.getProcessInstanceId())
.singleResult().getBusinessKey();
William R.
2 Likes
Your welcome @moshell !
Please remember as a best practice, when an answer solves your problem in the topic, mark this answer as a solution so that other users searching for the same problem will know which answer helped to solve it.
Kind Regards.
William Robert Alves
2 Likes
execution.getBusinessKey();
This is a valid method for the JavaDelegate class, you can elaborate if you want to achieve this in another context.
3 Likes
system
Closed
September 27, 2023, 5:54pm
7
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.