Unable to parse a list a object in dmn while calling from postman

Hello , i am trying to get decision for multiple input , after researching all round I found a post on this forum and have followed that to create a multi-instance process and passing each object to decision table, appending to array,

I am creating post man request with payload like :
{
“variables”:{
“companies”:
{
“type”: “Object”,
“value”: “[{"cid":20},{"cid":21}]”,
“valueInfo”: {
“objectTypeName”: “java.util.ArrayList”,
“serializationDataFormat”: “application/json”
}
}
}
}
this throws following error when it is trying to append to the array :
Cannot instantiate process definition PersonData:17:5e101cd8-fe69-11ef-87dd-be07c191b0d2: Unable to evaluate script while executing activity ‘Activity_1y9uuz1’ in the process definition with id ‘PersonData:17:5e101cd8-fe69-11ef-87dd-be07c191b0d2’: groovy.lang.MissingMethodException: No signature of method: java.lang.String.putAt() is applicable for argument types: (java.lang.Integer, java.lang.String) values: [1, safe]\nPossible solutions: putAt(java.lang.String, java.lang.Object), getAt(java.lang.String), getAt(int), getAt(int), getAt(groovy.lang.Range), getAt(java.util.Collection)"

also when i only pass a single variable from pastman it throws the following error: no javascript engine found

Can someone help me out , stuck at this from a couple of days, here are the files attached
CompanyCheck.bpmn (5.3 KB)

diagram_1.dmn (1.5 KB)

Hi @Aryan_Agarwal, thanks for your question - the result variable in a script task is set to the return value of the last statement in your script. In your case, with groovy, array assignment returns the value being assigned rather than the array itself. Hence your array process variable is overwritten by the last assignment value.

Option 1 - make the last statement of your script the name of the array:

if(execution.getVariable('resultsSafety') == null) {
resultsSafety = new String[nrOfInstances]
}
resultsSafety[loopCounter] = safety
resultsSafety // will be assigned to result variale

Option 2- remove the result variable config of the task and explicitly set the process variable in your script:

if(execution.getVariable('resultsSafety') == null) {
resultsSafety = new String[nrOfInstances]
}
resultsSafety[loopCounter] = safety
execution.setVariable('resultsSafety', resultsSafety) // explicitly manage the variable 

I think either should work.

Also, the postman request defines companies variable but the model you uploaded “needs” persons

2 Likes

thank you @herrier herrier , i was able to solve the problem

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.