Pattern Review: DMN Looping for Array Input


#22

@steftriant the readme outlines what to do in the pom and in the processes.xml file. Which part of the read me are you unsure about?


#23

@StephenOTT, I’m not sure at which line of my pom xml file, I must include the repository source (JitPack) because I haven’t included until now any similar source as you can see in my attached file here.
Could you please edit my attached pom xml file here as far as the plugin installation as a dependency is concerned ?

Thanks a lot,
Steve


#24

Hi @StephenOTT.

I’ve been trying to apply your steps in my BPMN model and I would like to ask you some points:

  1. What does the “jsonValue” represent ? The final json variable which includes the values from all completed instances ?
  2. What does the “values” represent ?
  3. The “combinedResult” variable represents some collection (e.x. of users) or the final json variable which includes the values from all completed instances ?
  4. What does the “user” represent here ?
var combinedResult = execution.getVariable("combinedResult");
var dmn_output = execution.getVariable("dmn_output")["user"];

combinedResult.prop("values").append(dmn_output)

execution.setVariable("combinedResult", combinedResult)

I’m asking all these as I’ve been trying to make clear (in my example) the meaning of each variable.

Thank you in advance for your time,
Steve


#25
  1. Json value is the variable that is updated in each iteration of the multi-instance. Look at the BPMN files and see the listeners on the multi-instance.

  2. Values is just a generic property name i used within the json. Each object result of the mulit-instance integration is added into the json in the “values” property’s array.

  3. combined result is a json variable that is updated on each iteration. See the listeners as discussed above.

  4. See the DMN file and the dmn_output variable. It is a map that is result and navigated. Remember that this is navigated as Java with the Jackson helpers on top. So you need to look at the cockpit and understand the types that are being saved in the DB and being returned to

The code snippet of

var combinedResult = execution.getVariable("combinedResult");
var dmn_output = execution.getVariable("dmn_output")["user"];

combinedResult.prop("values").append(dmn_output)

execution.setVariable("combinedResult", combinedResult)

is doing:

  1. get the combined result variable which holds the current aggregated result of all executed instances
  2. get the user value from the DMN result (the output of the DMN was saved into the dmn_output variable).
  3. inside of the combinedResult variable in the “values” property, we apparent the dmn_output user value into the array.
  4. We re-save the new variable which overwrites the previous version of the combined result variable.

#26

Hi again @StephenOTT and thanks for your immediate reply. :slightly_smiling_face:

Based on the above points, I tried again to run my BPMN model (which is slightly different from your example) but without any success again.
When I try to complete the 1st instance of my Subprocess, I’m always taking the following server error:
SPIN/JACKSON-JSON-01005 Unable to create node for object of type 'Undefined’

test.bpmn (7.8 KB)

If you take a look at my BPMN file, you can see that:

  1. I’ve used an Execution Listener instead of a Script Task for the Array generation just before the Multi-Instance Subprocess starts.
  2. I’ve used the “aggregatedList” as the json variable which is updated on each iteration and holds the current aggregated result of all executed instances.
  3. My collection array variable consists of multiple users (instead of multiple systems as in your example)
  4. Inside of the “aggregatedList” variable in the “values” property, I append the “selectedProduct” user’s value (which is created on the completion of each instance into the Subprocess via camForm function).

Could you please tell me what I’m doing wrong? :confused:

Thanks a lot,
Steve