How to gather the output of a parallel multi-instance sub-process?

Lazar Ivkov: Hey everyone! I have a clarifying question on gathering the output of a parallel multi-instance sub-process (I’ll shorten it to MISP in future).

If MISP receives a JSON array, for example, "files":[{"id":1, "status":""}, {"id":2, "status":""}, {"id":3, "status":""}] - and in MISP I have tasks which work on individual items from this files array, and they all, at the end, Complete() their tasks by Send()ing their updated items like: "file":{"id":1, "status":"done"} then is it possible to, after MISP ends, to have an array of all the updated items from that files array? I’m trying out some stuff, but I can’t seem to get it to work. I’m getting an array of "output":[null,null,null] as the input to the next task which should operate on the updated files array, but I need to know the status of each of the previously processed file.

What I’m wondering: is it at all possible, or should I abandon my approach?

Thomas Heinrichs: Hi Lazar, I guess you have already seen this documentation:

Could this be the issue why you receive an array with null values?: “If the outputElement variable is not updated, null is inserted instead.”

korthout: You cannot use a parallel multi-instance to update the variable it iterates over. For a detailed description of this behavior please have a look at|camunda-cloud/zeebe#7330. We still need to update the docs to make this easier to understand.

As a solution, please use use a different variable name for the modified list.

As a workaround to modifying the list variable: wrap the parallel multi-instance element with a sub process that defines an output mapping taking the output of the parallel multi-instance element as source and targeting the original variable that was iterated over. This would overwrite the variable.

See the discussion in the linked issue for more details on the workarounds

Note: This post was generated by Slack Archivist from a conversation in the Zeebe Slack, a source of valuable discussions on Zeebe (get an invite). Someone in the Slack thought this was worth sharing!

If this post answered a question for you, hit the Like button - we use that to assess which posts to put into docs.