Idiomatic solution for the 1-n problem

I’m looking at the examples site here where you talk about the 1-N problem:

A process spawns a number of sub processes. In the you collect a bunch of orders from a marketplace and then process each one by creating a sub process. It seems to me that if this BPMN diagram were to be executed in comunda only one sub process would ever be created, no matter what the code in the “Collect all orders from marketplace” task did.

I’m wondering whether that bpmn diagram is actually something that could be executed in camunda to spawn many sub process. If so, perhaps someone could point me to an implementation. If it’s just a modelling exercise then I imagine an executable version is a matter of two separate process diagrams. A process that checks the marketplace for orders and creates the “Process Order” process. Am I right either way?

Thanks in advance.


Robert Moskal
Brooklyn, USA

Hi Robert,

The sub-process is a multi-instance sub-process (the three vertical bars indicate this). hence your could interpret the process model as;

Every 10 minutes, check and collect all unprocessed orders.
For each order collected, check order, import to ERP.

Documentation of multi-instance task markers can be found at [1]

Hope this helps,

regards

Rob

[1] https://docs.camunda.org/manual/7.5/reference/bpmn20/tasks/task-markers/

@rmoskal the sub-process in that example has the multi-parallel marker.

@Webcyberrob you beat me too it as i was doing a test to confirm it actually works :slight_smile:
@rmoskal the “trick” is you need to generate a “collection” variable. little more tricky if you are using JS.

Here is a example:

multisubtest.bpmn (6.3 KB)



1 Like

@camunda I believe there is a bug when multi-instance sub-processes when using generated forms.

If you take the BPMN file from above, and add a form validation rule of readonly for the OrderName form field, the Order001 task can be completed, but when you try and complete the Order001 task, the ReadOnly validation error kicks in, even though the field was only read only and there was no difference between Task 1 and Task 2 that was generated.

@camunda can the variable Type API be accessed from JS? Is there a ability to type to a collection value?

Thanks so much. You’ve all been helpful.