06-20-2018 08:51 AM
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
07-02-2018 08:08 AM
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;
}
07-02-2018 09:02 AM
My bad. The correct call should be like this.
historyService.createHistoricProcessInstanceQuery()
.or()
.variableValueEquals("location", "US")
.variableValueEquals("location", "UK")
.endOr()
.list();
07-17-2018 03:44 AM
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?
07-17-2018 04:29 AM
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()
07-17-2018 05:52 AM
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?
07-17-2018 06:13 AM
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.
Explore our Alfresco products with the links below. Use labels to filter content by product module.