How to 'join' process instances while filtering?

Hy everyone!

I’m new in Camunda so my question is probably stupid, but…
I have two ‘related’ process definitions. Their instances are related like parent-child. But I don’t see a way to really connect these instances (please tell me if there is a way).

And now the issue. Let us have processes A and B where B is a child process for A. In my case, I store processInstanceId of A into B. And I want to get all instances of type A having a specific value for some vars in B. Is it possible? What I have to do to reach it?

I think what you’re looking for here is a business key.
Giving difference instances the same business key will make it really easy to query for them. You can read more about it in this blog post.

No, they have different businessKey because they are from different process definitions.

Example: I have processes for Order and Document. And each Order may have (relate) some Documents. And I want to find orders which have documents with specific variables.

As I understand, the same businessKey means the same business process workflow, but it’s not what I need.

Actually business keys can represent multiple processes instances, it’s the main feature behind them.
The idea being that the process instance id is locked to a specific instance but a business key can actually represent lots of different instances for the purpose of grouping together related instances by one related key.

So it’s actually suited perfectly for what you need.

1 Like

Hm. But when I start the process instance I send a business key and Camunda starts the process instance of process definition with the same name. So I don’t understand how it works :confused:

So you mean the business key it’s not like “type of processes”, but it’s like “id of the group of all (sub)processes related to the same business process”?

Step 1 : Create an Order workflow instance with business key as “Order1”
Step 2 : Create 5 Document workflow instances with business key as “Order1”.

This way, while filtering with certain variables in Document instances you will get a single business key/ list of business keys (which in this case is “Order 1”). Use the same business key/keys to retrieve all the related Order workflow instances. ie. Order instances having the same business key.

Hope this helps!!!

I don’t think you really understand what is my goal. I don’t have to get Orders and Documents in one filter query. Instead, I want to get Orders that have connected documents with some variables. If I used a single business key for both orders and documents I need to postfilter them manually to separate only orders.
On SQL it would be something like this:
SELECT o.* FROM orders o JOIN documents d ON d.order_id = WHERE d.var = value

I was searching for a similar solution combining executions together, but I didn’t find anything and I think it is not possible, because it would need a special BPMN component, that doesn’t exist. It’s really a pity.