问题描述
我正在尝试将两个数组合并为一个对象数组并将此对象设置为变量以供进一步使用。 使用脚本格式“javascript”和脚本类型“内联脚本”。
下面是我正在尝试的代码。
var A_Group = execution.getvariableTyped("A_Group",true).getValue()
var B_Group = execution.getvariableTyped("B_Group",true).getValue()
var groupList = new Array
for(var i=0; i<A_Group.length;i++){
for(var j=0;j<B_Group.length;j++){
groupList.push({
"A_Group" : A_Group[i],"B_Group" : B_Group[j]
});
}
}
execution.setvariable("GroupList",groupList);
500 内部服务器错误
{
"type": "RestException","message": "Cannot instantiate process deFinition Process_11qsgp3:3:0c411f07-4944-11eb-9f3b-5c80b61f42fc:
Cannot serialize object in variable 'GroupList': SPIN/DOM-XML-01030 Cannot create context"
}
拜托,任何线索都会有所帮助。如果不清楚,请在评论中询问。
谢谢!
解决方法
你看到 https://forum.camunda.org/t/error-while-parsing-json-output-spin-dom-xml-01009/7976 了吗? 您发送的数据可能存在问题。
您可能还想考虑使用 JS 方法 concat 代替 https://www.w3schools.com/jsref/jsref_concat_array.asp
还有:
可通过执行访问的所有流程变量 到达脚本任务可以在脚本内使用。
https://docs.camunda.org/manual/latest/reference/bpmn20/tasks/script-task/