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

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

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
bassam_al-saror
Alfresco Employee

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

I'm not sure I understood what are you trying to do. Do you want to do a query that returns process instances based on those values (form field values)?

Can you also specify whether you are using Activiti or APS and what version?

shilpak
Active Member II

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

Yes. I want to do a query that returns process instances based on form field values.

I am using APS 1.7.

bassam_al-saror
Alfresco Employee

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

You can query based on process variables values. For example,

POST api/enterprise/historic-process-instances/query
{"variables":[{"name":"myVar","value":"US","operation":"equals"}]}
shilpak
Active Member II

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

Thank youbassam.al-sarori  for the solution. It worked for me. In my case I want to pass multiple values for the value. For example, I have to pass "US", "India", "UK" etc... as value. Is this possible to pass multiple values at once? 

bassam_al-saror
Alfresco Employee

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

multiple values can be submitted using data tables.

shilpak
Active Member II

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

Can you please provide any example or documentation link?

bassam_al-saror
Alfresco Employee

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

Sorry I meant dynamic tables can be used for multiple values (rows).

shilpak
Active Member II

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

I want to fetch the process instances of multiple locations. For this I am using following swagger api:

http://localhost:8082/activiti-app/api-explorer.html#!/process-instances/getHistoricProcessInstances... 

For this I have passed the process variable value as you suggested. 

If I pass single location name then it is working properly.I am getting the process instances of that location . I have tested this in the postman. I am attaching here those screens:

Scenario 1: Fetching process instances of puna location(by variables [name as location and value as puna])

I am passing variable name as location and value as puna

For this request I am getting following response[this location has 2 records[process instances] so I am getting those 2 records:

Response data for puna location

Scenario 2: Fetching process instances of banglore location(by variables [name as location and value as banglore])

I am passing variable name as location and value as banglore

For this request I am getting following response[this location has 3 records[process instances] so I am getting those 3 records:

Response data for banglore location

Scenario 3: I want to fetch the process instances of these 2 locations [banglore and puna]. I am sending request as follows:

I am passing multiple variable names as location and value as puna and banglore

Ideally I should get the process instances of those 2 (bangloe and puna)locations. I should get 5 records  in the response. But I am not getting any records but still response code is 200. I am getting the response as follows:

Response data for multiple location[banglore and puna]

Why I am not getting the records if I pass multiple locations for variable value[Scenario 3]? Am I passing request in proper format or is there any other way to pass the multiple values for the variables for fetching the process instances?

bassam_al-saror
Alfresco Employee

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

The query will check for process instances that have all the variables included in the request. 

{"variables":[
               {"name":"foo","value":"bar","operation":"equals"},
               {"name": "location", "value":"US", "operation":"equals"}
            ]
}

The above will return only processes that have both "foo" and "location" with the specified values. The query uses the "AND" clause.

You can create a custom REST endpoint that uses HistoricProcessInstanceQuery (Activiti - Engine 5.22.0 API)  

historyService.createHistoricProcessInstanceQuery()

              .or()

                .variableValueEquals("location", "US")

              .endOr()

              .or()

                .variableValueEquals("location", "UK")

              .endOr()

              .list();