欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

如何在调用Camunda原生RESTAPI接口时给多实例节点传入集合变量

时间:2023-06-19

Camunda提供了多种类型的变量类型支持,详情请查看官方文档

多实例节点属性有集合变量,常用于并审或调用子流程节点,示例如下:

多实例节点-人工任务-并审-集合变量名:assigneeList

<?xml version="1.0" encoding="UTF-8"?> Flow_1lqot0o Flow_0qdzfen Flow_1lqot0o Flow_0yuchf0 Flow_0yuchf0 Flow_0qdzfen ${nrOfCompletedInstances==1}

多实例节点-调用子流程-并行-集合变量名:itemList

<?xml version="1.0" encoding="UTF-8"?> Flow_1kmyk0u Flow_1kmyk0u Flow_0cmzdl8 Flow_0cmzdl8

修改pom.xml文件,添加以下依赖:

org.camunda.bpm camunda-engine-plugin-spin org.camunda.spin camunda-spin-dataformat-all

重启服务,并部署模型,部署成功后,打开Postman或ApiPost等客户端,参考原生REST API Start Process Instance | docs.camunda.org 发起流程

请求报文:

{ "variables":{ "assigneeList":{ "value":"["bx2","bx3"]", "type":"Object", "valueInfo":{ "objectTypeName":"java.util.ArrayList", "serializationDataFormat":"application/json" } }, "starter":{ "value":"bx1", "type":"String" } }, "businessKey":"myBusinessKey2", "withVariablesInReturn":true}

响应报文:

{ "links":[ { "method":"GET", "href":"http://127.0.0.1:8080/engine-rest/process-instance/d593cf3e-8cac-11ec-b78f-8c1645647a47", "rel":"self" } ], "id":"d593cf3e-8cac-11ec-b78f-8c1645647a47", "definitionId":"Process_1fh6max:1:89fe12a3-8c7e-11ec-a02b-8c1645647a47", "businessKey":"myBusinessKey2", "caseInstanceId":null, "ended":false, "suspended":false, "tenantId":null, "variables":{ "assigneeList":{ "type":"Object", "value":"["bx2","bx3"]", "valueInfo":{ "objectTypeName":"java.util.ArrayList", "serializationDataFormat":"application/json" } }, "starter":{ "type":"String", "value":"bx1", "valueInfo":{ } } }}

 登陆WebApp并切换到Tasklist执行提交节点任务到提交,检查是否可以正常提交,以及并审任务节点是否可以产生2个任务实例

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。