How to return a variable form an embedded form on a multi-instance subprocess

Hello all

I would like to collate the various “Approved” Boolean responses on a form served as multiple parallel instances of a sub-process.
I suspect I would have to initialize a JSON process variable, vJsonResponses, before the MI process is activated and then add a property to it for each instance of the MI. However I cannot get the variable to update.

Why is the Json variable not updating? Can this be done with EL / JS?

Test-MultiInstance-01.bpmn (9.1 KB)

@eugene take a look at:

In that thread, there is code example of running Multi-Instance on a Business Rule Task and for the output of each instance, the result is added to a array/collection. This should cover your use case to show the collated boolean responses in your Collate user task.

Thanks Stephen

I had a look at your link, but fail to see where I’m going wrong. Is my vJsonResponses.prop(loopCounter,vApprove); correct?

Can you confirm that doing setVariable('vJsonResponses', JSON("{}")) works?

Yip. In both Cockpit and on the final Collate form it appears as a JSON object, {}

I believe your problem is that in your End Listener on the Approve User Task, you are not updating the process variable. Look at my code examples from the DMN pattern.

Also take a look at how to work with JSON arrays with SPIN: https://docs.camunda.org/manual/7.6/reference/spin/json/01-reading-json/#work-with-json-arrays

Okay, I got it working, but no idea of how above-board this is, there might be a much better way of doing it:

Replace the vJsonResponses.prop(loopCounter,vApprove); with
execution.setVariable(‘vJsonResponses’,vJsonResponses.prop(loopCounter,vApprove));

Thanks for all your assistance @StephenOTT