我有一个简单的bpmn,只有脚本任务设置一个过程变量和一个接受两个输入参数,一个输出参数并定义了一个表单数据字段的人工任务。
启动流程后,执行将停止在人工任务上。然后我尝试获取人工任务表单的变量(即输入变量和\或表单数据字段,但不是屏幕任务设置的执行变量)。
查询REST API的结果如下:
我无法理解为什么脚本任务变量与其他表单变量一起返回。
如何只获取输入变量和表单数据字段,而不是屏幕任务变量(以及可能的所有其他过程变量)? 编辑:我不想使用查询参数来选择变量名。
我正在使用Camunda Widlfly 10.0.0。
我正在使用的bpmn:
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.3.0">
<bpmn:process id="userTaskExample" isExecutable="true">
<bpmn:startEvent id="StartEvent_02mu30n">
<bpmn:outgoing>SequenceFlow_14v3dyf</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:endEvent id="EndEvent_144sl4n">
<bpmn:incoming>SequenceFlow_0acu0wh</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_0acu0wh" sourceRef="Task_096f7n7" targetRef="EndEvent_144sl4n" />
<bpmn:userTask id="Task_096f7n7" name="user task sk">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="form_1" label="form_1" type="string" defaultValue="form_1_" />
</camunda:formData>
<camunda:inputOutput>
<camunda:inputParameter name="input_1">input_1_val</camunda:inputParameter>
<camunda:inputParameter name="input_2">input_2_val</camunda:inputParameter>
<camunda:outputParameter name="output_1">output_2</camunda:outputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_0sulfwg</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0acu0wh</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="SequenceFlow_14v3dyf" sourceRef="StartEvent_02mu30n" targetRef="Task_0cphzp1" />
<bpmn:sequenceFlow id="SequenceFlow_0sulfwg" sourceRef="Task_0cphzp1" targetRef="Task_096f7n7" />
<bpmn:scriptTask id="Task_0cphzp1" name="script task sk" scriptFormat="groovy" camunda:resultVariable="script_task_variable">
<bpmn:incoming>SequenceFlow_14v3dyf</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0sulfwg</bpmn:outgoing>
<bpmn:script><![CDATA["scipt task variable"]]></bpmn:script>
</bpmn:scriptTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="userTaskExample">
<bpmndi:BPMNShape id="StartEvent_02mu30n_di" bpmnElement="StartEvent_02mu30n">
<dc:Bounds x="151" y="66" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="169" y="102" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_144sl4n_di" bpmnElement="EndEvent_144sl4n">
<dc:Bounds x="616" y="66" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="634" y="102" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0acu0wh_di" bpmnElement="SequenceFlow_0acu0wh">
<di:waypoint xsi:type="dc:Point" x="433" y="84" />
<di:waypoint xsi:type="dc:Point" x="524" y="84" />
<di:waypoint xsi:type="dc:Point" x="524" y="84" />
<di:waypoint xsi:type="dc:Point" x="616" y="84" />
<bpmndi:BPMNLabel>
<dc:Bounds x="539" y="84" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="UserTask_1lppvq8_di" bpmnElement="Task_096f7n7">
<dc:Bounds x="333" y="44" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_14v3dyf_di" bpmnElement="SequenceFlow_14v3dyf">
<di:waypoint xsi:type="dc:Point" x="169" y="102" />
<di:waypoint xsi:type="dc:Point" x="169" y="133" />
<di:waypoint xsi:type="dc:Point" x="252" y="133" />
<di:waypoint xsi:type="dc:Point" x="192" y="204" />
<di:waypoint xsi:type="dc:Point" x="275" y="204" />
<di:waypoint xsi:type="dc:Point" x="275" y="284" />
<bpmndi:BPMNLabel>
<dc:Bounds x="222" y="153.5" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0sulfwg_di" bpmnElement="SequenceFlow_0sulfwg">
<di:waypoint xsi:type="dc:Point" x="325" y="331" />
<di:waypoint xsi:type="dc:Point" x="401" y="342" />
<di:waypoint xsi:type="dc:Point" x="383" y="204" />
<di:waypoint xsi:type="dc:Point" x="383" y="124" />
<bpmndi:BPMNLabel>
<dc:Bounds x="392" y="258" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ScriptTask_1q3eqsu_di" bpmnElement="Task_0cphzp1">
<dc:Bounds x="225" y="284" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
答案 0 :(得分:2)
您的结果表明您正在人工任务表单中显示脚本任务中定义的变量。 我这样说是因为当您查看源代码以检索表单变量时,我们会看到:
extern int c;
请注意,我们对表单字段定义进行了检查以检索我们关心的变量名称,然后从执行上下文中填充数据。
最终Activiti / Camunda(它们在引擎级别的90%相同)不区分表单中输入的数据和脚本或服务任务中创建的数据(例如作为结果变量)。
如果由于某种原因需要将它们分开,我建议您使用命名约定并根据变量名约定查询过程变量。