cancel
Showing results for 
Search instead for 
Did you mean: 

Get process instances history for a specific object

pedrog1
Champ in-the-making
Champ in-the-making
Hi everyone

In my app I'm building workflows and I want to get the history of the workflows triggered for a specific object.

When the workflows are executing, is easy to retrieve the workflows for that entity/object, the API gives everything is needed, but when it ends and it's needed to be accessed via History API I can't find a way to retrieve those objects.

I will try to explain how I do it.

This is how I start a workflow

Map<String, Object> variables = new HashMap<String, Object>();

variables.put("my_object_class", myObject.getClass().getName());
variables.put("my_object_id", myObject.getId());

runtimeService.startProcessInstanceByKey(processDefinitionKey, variables);

This is how I retrieve ongoing workflows for my object

private List<ProcessInstance> returnProcessInstances(MyObject myObject) {
   Map<String, Object> variables = new HashMap<String, Object>();

   variables.put("my_object_class", myObject.getClass().getName());
   variables.put("my_object_id", myObject.getId());

   for(Map.Entry<String, Object> variable : variables.entrySet()) {
      query.variableValueEquals(variable.getKey(), variable.getValue());
   }
   return query.list();
}

I have the history in full mode, so everything is persisted in the DB.
How can I access the BD and retrieve the process instances with the variables provided? Should I do it in a different way?

Thanks
10 REPLIES 10

jbarrez
Star Contributor
Star Contributor
Could you tell me which unique constraint? Can't find it in the posts above>

If its about the unique business key - process definition id constraint, I removed that a few weeks ago on master