簡體   English   中英

當值是 Camunda 中的數組時如何在腳本任務中設置變量

[英]How to set variable in Script Task when Value is an Array in Camunda

我正在嘗試將兩個數組合並為一個 Object 數組並將此 Object 設置為變量以供進一步使用。 使用腳本格式“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/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM