I have several BPM diagrams written in seperate files and I’m using “message” events to start the associated processes. The process(es) that need(s) to be started depend(s) on the result of a Business rule task.
Example: If my DMN input is “key_1” then two processes should be started, one process that is launched with a “message” start event containing “out_1” and a second process that is launched with message “out_2”.
I use a multitask subprocess philisophy to loop over “out_1” and “out_2”. Here is the simple image of my diagram:
Thanks for your quick reply. I checked your proposed solution, which is indeed really nice to append elements to a json variable when combining multi-instance and DMN tasks. However, my case is slightly different from yours in the way that my output is a fixed array, it shouldn’t grow by appending elements in values like in your combinedResult json.
In my case, a single output should be the json variable, something like: S('{"values":["out_A","out_B"]}')
Then, from there, I could use your solution to send messages using multi-instance on json collection.
However when deploying my table and running the instance I get the following message from the cockpit: The process could not be started. : Cannot instantiate process definition master_loop:13:4c49532c-0539-11ea-bdca-50eb7136ed6c: Cannot serialize object in variable 'decisionResult': org.camunda.spin.impl.json.jackson.JacksonJsonNode
My question should be then, can I output a JSON variable containing my array directly from my DMN without using multi-instance?
(NB: creating an empty JSON output before the DMN and looping over DMN task to feed array sounds overly complex for that simple purpose)
A multi instance just requires a java collection. So the output of the dmn that generates a array should be a collection. Then just pass that collection as the elements for your multiinstance
Yes you’re right @StephenOTT, but the challenge is to create the collection in the DMN table without using a multi-instance (as a collection type is not supported in the DMN). So I use string.split(",") in my DMN listener to create this array but then I get: Cannot serialize object in variable 'array': SPIN/DOM-XML-01030 Cannot create context
Something might be wrong in my inline script but I don’t get it… var str=execution.getVariable("dmn_output") var array=str.split(",") execution.setVariable("array",array)
My DMN output is a single string, for example, “out_A,out_B”
It works perfectly now with the collect hit policy approach, thanks a lot for your time and concern. Here is in my illustrated example and the associated BPMN and DMN files.