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.
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.