cancel
Showing results for 
Search instead for 
Did you mean: 

Fetch the process instances by passing the multiple business key[processBusinessKey] values.

shilpak
Confirmed Champ
Confirmed Champ

Hello,

I have one process which has task and form fields. And I have one field "location" which I am considering as business key.  For example, I have 2 locations as: India and UK. I want to fetch the process instances of these two locations. Means I need to pass the multiple business key values. Is it possible to pass the multiple business key values and fetch the process instances of these 2 business key values [multiple business key values]?

Thanks & Regards 

Shilpa Kulkarni

15 REPLIES 15

I have created custom rest endpoint and added the query you suggested. But I am getting result as empty array even though I have records. I have written as follows:

@Timed
@RequestMapping(value = "/processInstances/{id}", method= RequestMethod.GET)
public String processInstances(@PathVariable String id) {

List<HistoricProcessInstance> processes = historyService.createHistoricProcessInstanceQuery()

.or()

.variableValueEquals("location", "banglore")

.endOr()

.or()

.variableValueEquals("location", "puna")

.endOr()

.list();
System.out.println("processes are as follows:\n");

System.out.println("get class"+processes);

return "INSIDE PROCESS INSTANCES..."+processes;
}

My bad. The correct call should be like this.

historyService.createHistoricProcessInstanceQuery()

              .or()

                .variableValueEquals("location", "US")

                .variableValueEquals("location", "UK")

              .endOr()

              .list();

Thank you Bassam Al-Sarori‌. It is working propelry. I am getting process instances of different locations. I also want to pass processDefinitionKey in the query. Means it should check those locations and also should check for that processDefinitionKey. And also I want number of records[number of process instances in the result]. Can you please provide solution?

You can add the process definition key to query like this (outside or endOr)

historyService.createHistoricProcessInstanceQuery()

              .processDefinitionKey("myKey")

              .or()

                .variableValueEquals("location", "US")

                .variableValueEquals("location", "UK")

              .endOr()

              .list();

To get results count you can use count() instead of list()

Thank you. Is this possible to get response as list of records with size and total. Means I want all records and also the size and total number of records. Is this possible?

Two queries will need to be executed. One for the count and another for the results. But both can be returned in the same response. You can use ResultListDataRepresentation<ProcessInstanceRepresentation> to get a similar response to what is returned by the standard REST query response.