Is there the equivalent of execution.getCurrentActivityId() for the process key (id)? In other words, if I’m in a delegate class and want to know the name of the process that is executing that class, how do I get it?
I wrote a script that executed each (those that made sense) of the “execution.get…” methods to see what they produced and none of them produced the process key. I do not want to go through the REST API and I would very much prefer not to have to make a database call to lookup the key using the process definition id.
here is some groovy script which I have used to get the process definition key. This reference to super process instance is I needed this code to also work in the context of a child subprocess…
def engineServices = execution.getProcessEngineServices();
def superExecution = execution.getProcessInstance().getSuperExecution();
def processDefinitionKey = engineServices .getRepositoryService().getProcessDefinition(superExecution.getProcessDefinitionId()).getKey();
I was able t adapt this to my Java code for use within a single process as follows:
ProcessEngineServices engineServices = execution.getProcessEngineServices();
String processDefintionKey = engineServices.getRepositoryService().getProcessDefinition(execution.getProcessDefinitionId()).getKey();