I am trying to pass an array into a multi-instance subprocess and then evaluate each element of array inside a decision table. I am grabbing my list from an external task where the variable name is “Activity”. It looks like the array is being passed into the multi-instance but it is happening as one complete string instead of each individual element of array being looped over.
The external task is a python worker and the array is being passed into the multi-instance as type java.util.arraylist. In this case Activity = [‘99204’, ‘77290’]
Is there something in my set up that is preventing me from looping through each element individually?
1 Like
@Jonathan_Schmitt, you need to configure “Element Variable” which is an iteration variable for the collection in multi instance activity.
Refer the below example:
@Slf4j
@Component
public class JobProducerDelegate implements JavaDelegate {
private static final String JOB_LIST = "jobList";
@Override
public void execute(DelegateExecution execution) throws Exception {
String category = (String) execution.getVariable("category");
log.info("VariableMap:{}", category);
if ("inventory".equals(category)) {
execution.setVariable(JOB_LIST, Arrays.asList("2000", "4000"));
} else if ("order".equals(category)) {
execution.setVariable(JOB_LIST, Arrays.asList("1000", "3000"));
} else {
execution.setVariable(JOB_LIST, Arrays.asList("0000"));
}
}
}
@Slf4j
@Component
public class LoggingExecutionListener implements ExecutionListener {
@Override
public void notify(DelegateExecution execution) throws Exception {
log.info("jobType:{}", execution.getVariable("jobType"));
}
}
BPMN File: JobProducerProcess.bpmn (6.4 KB) DMN File: jobIdentificationRule.dmn (1.9 KB)
Optimize Report:
3 Likes
Thank you. My example worked after I changed Collection = ${Activity} and Element Variable = activityid plus I also changed my input name in my DMN table from Activity to activityid.
2 Likes