How to get businessKey using runtimeService?


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()

        var businessKey = processInstance.getBusinessKey();

I hope this helps!

William Robert Alves

1 Like

You can do it this way if you want to simplify:

        var businessKey = execution.getProcessEngineServices().getRuntimeService()

William R.

1 Like

Thanks a lot!

1 Like

Your welcome @moshell ! :smile: :rocket:

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. :smile:

Kind Regards.
William Robert Alves

1 Like

This is a valid method for the JavaDelegate class, you can elaborate if you want to achieve this in another context.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.