How to pass information between user tasks

What is the best approach to pass information between two user tasks in a multi instance sub process and then evaluate the information in service tasks ?

Knowing that the number of iterations can vary.

We have tried different approaches listed below:

1ª with call activity
image

With this approach the problem I am having is that the name of the output variables has to be defined on the bpmn but the number of iteration can vary so I can’t define all the different output variables.

2ª with sub process
image

When I complete the UT1 with input variables to add information to the UT2 the variables are added to the main process instance so they are overwritten.

Hi Hugomar.

I had the same problem when I tried to run simulation run as a part of simulation experiment in the process execution.
https://gromar01.wordpress.com/2017/11/07/will-we-meet-our-kpis/
process model is

I took the first approach. The amount of output variables “challenge” was solved in the Evaluate sim run result task:

<scriptTask id="evaluate" name="Evaluate simulation run results" scriptFormat="groovy">
    <script>
        <![CDATA[
        if (isEscalated) {
            execution.getParent().setVariable("escalated", escalated+1);
        }
        println(" progress: " + (loopCounter+1) + "%");
]]>
    </script>
</scriptTask>

In your case I would create a list of results in the scope of parent process. Each iteration could add the output to the specific index (or in the map with specific id) to the list. or just create a variable with the specific name
e.g.

<scriptTask id="evaluate" name="Evaluate simulation run results" scriptFormat="groovy">
    <script>
        <![CDATA[
            execution.getParent().setVariable("escalated" + loopCounter, escalated+1);
]]>
    </script>
</scriptTask>

The script creates variable escalated1, escalated2,…, escalatedX.

Another possibility is to store output outside of the engine as it is done in
https://gromar01.wordpress.com/2018/09/12/crystalball-simulation-experiment-with-flink/

There are many other possibilities for sure, let me know if it does not help.

Martin

1 Like