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

cancel
Showing results for 
Search instead for 
Did you mean: 
shilpak
Active Member II

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

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;
}

bassam_al-saror
Alfresco Employee

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

My bad. The correct call should be like this.

historyService.createHistoricProcessInstanceQuery()

              .or()

                .variableValueEquals("location", "US")

                .variableValueEquals("location", "UK")

              .endOr()

              .list();

shilpak
Active Member II

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

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?

bassam_al-saror
Alfresco Employee

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

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

shilpak
Active Member II

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

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?

bassam_al-saror
Alfresco Employee

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

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.