I'm trying to handle a PROCESS_COMPLETED event by creating an ActivityEventListener bean:
@Override
public void onEvent(ActivitiEvent event) {
final ProcessInstance processInstance = event.getEngineServices().getRuntimeService()
.createProcessInstanceQuery().processInstanceId(event.getProcessInstanceId())
.includeProcessVariables().singleResult();
}
first of all event.getProcessInstanceId() returns an id that does not exist in the database, second ProcessInsantceQuery seems to only return process instances that are not completed(hence processInstance == null). My goal is to get the variables of every process instance that is completed. how can I achieve this?
I was able to get the variable I wanted like this:
String var = (String) ((ExecutionEntity) ((ActivitiEntityEventImpl) event).getEntity()).getVariable("var");
And I noticed that the id returned by event.getProcessInstanceId() will exist in the database after event handling is finished. Perhaps only the history of the process instance is saved in that table. My problem is fixed; but still it would be nice to be able to query finished process instances and unfinished alike.
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.