Hi have a Process model, where the multi instance sub process is present as shown below.
The Step 1 human task is linked with the below embedded form.
firstForm.html
<form role="form" class="form-horizontal">
<script cam-script type="text/form-script">
var system = $scope.systems = [{'systemName':''}];
camForm.on('form-loaded', function() {
camForm.variableManager.createVariable({
name: 'system',
type: 'Object',
value: system,
valueInfo: {
// indicate that object is serialized as json
serializationDataFormat: 'application/json',
// provide classname of java object
objectTypeName: 'java.util.ArrayList'
}
});
});
camForm.on('submit', function() {
// remove '$$hashKey' properties from address objects
angular.forEach(system, function(addr) {
console.log(addr);
delete addr.$$hashKey;
});
console.log(system);
});
$scope.addUser = function() {
var newUser = {'systemName':''};
$scope.systems.push(newUser);
};
$scope.removeUser = function(system) {
var index = $scope.systems.indexOf(system);
$scope.systems.splice(index,1);
};
</script>
<h1> Add Systems </h1>
<button class="btn btn-primary" ng-click="addUser()">Add System</button>
<div ng-repeat="system in systems">
<div class="row">
<div class="control-group">
<label class="control-label" for="systemName">Enter System <span>{{ $index + 1 }}.</span></label>
<div class="controls">
<input id="systemName" class="form-control" type="text" ng-model="system.systemName" required />
</div>
</div>
<button ng-click="removeUser(system)" ng-if="systems.length>1">Remove</button>
</div>
</div>
</form>
I have executionListener that gets executed at the end of Step 1 task. I am setting the collection variable in execution listener. Based on the size of the collection n number of sub process is invoked.
@Slf4j
public class DDMultiTaskDelegate implements JavaDelegate {
@Override
public void execute(DelegateExecution delegateExecution) throws Exception {
//Object object = delegateExecution.getVariable("system");
List<DDSystem> userSystems = (List<DDSystem>) delegateExecution.getVariable("system");;
delegateExecution.setVariable("systemList", userSystems);
}
}
I am trying to display the task variable for the step 2 task using the below code.
<form role="form" class="form-horizontal">
<script cam-script type="text/form-script">
camForm.on('form-loaded', function() {
// tell the form SDK to fetch the variable named 'customer'
camForm.variableManager.fetchVariable('sys');
});
camForm.on('variables-fetched', function() {
// work with the variable (bind it to the current AngularJS $scope)
$scope.system = camForm.variableManager.variableValue('sys');
});
</script>
<div class="control-group">
<h3>System Name : </h3> <span>{{system.systemName}}</span>
</div>
</form>
But when the variable is fetched it is not getting deserialized. I am getting the below response from the server for the rest call http://localhost:8081/api/engine/engine/default/task/6c46024e-ffbd-11e9-a7d3-005056b47730/form-variables?deserializeValues=false&variableNames=sys
{"sys":{"type":"Object","value":"rO0ABXNyABdqYXZhLnV0aWwuTGlua2VkSGFzaE1hcDTATlwQbMD7AgABWgALYWNjZXNzT3JkZXJ4cgARamF2YS51dGlsLkhhc2hNYXAFB9rBwxZg0QMAAkYACmxvYWRGYWN0b3JJAAl0aHJlc2hvbGR4cD9AAAAAAAABdwgAAAACAAAAAXQACnN5c3RlbU5hbWV0AAZBbWF6b254AA==","valueInfo":{"objectTypeName":"java.util.LinkedHashMap","serializationDataFormat":"application/x-java-serialized-object"}}}
Here is the 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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0o21fd8" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.2">
<bpmn:process id="camunda-test" name="Camunda Test Process" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1war6r2</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_1war6r2" sourceRef="StartEvent_1" targetRef="Task_1kw6h8b" />
<bpmn:userTask id="Task_1kw6h8b" name="Step1" camunda:formKey="embedded:app:forms/firstForm.html" camunda:candidateGroups="MetadataScanningTeam">
<bpmn:extensionElements>
<camunda:executionListener class="com.xyz.diw.service.DDMultiTaskDelegate" event="end" />
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1war6r2</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1n4omi3</bpmn:outgoing>
</bpmn:userTask>
<bpmn:subProcess id="SubProcess_16ii7vk" name="Secondary Sub Process">
<bpmn:incoming>SequenceFlow_1n4omi3</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0u0dpn4</bpmn:outgoing>
<bpmn:multiInstanceLoopCharacteristics camunda:collection="systemList" camunda:elementVariable="sys" />
<bpmn:startEvent id="StartEvent_0hmj9us">
<bpmn:outgoing>SequenceFlow_0k9gw4m</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_0k9gw4m" sourceRef="StartEvent_0hmj9us" targetRef="Task_0zfgdnv" />
<bpmn:sequenceFlow id="SequenceFlow_0awtesr" sourceRef="Task_0zfgdnv" targetRef="Task_0fl5f96" />
<bpmn:endEvent id="EndEvent_1sgs88n">
<bpmn:incoming>SequenceFlow_1f0yvsl</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_1f0yvsl" sourceRef="Task_0fl5f96" targetRef="EndEvent_1sgs88n" />
<bpmn:userTask id="Task_0zfgdnv" name="Step 2 - ${sys.systemName}" camunda:formKey="embedded:app:forms/dd-display-form.html" camunda:candidateGroups="MetadataScanningTeam" camunda:dueDate="P1W">
<bpmn:incoming>SequenceFlow_0k9gw4m</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0awtesr</bpmn:outgoing>
</bpmn:userTask>
<bpmn:userTask id="Task_0fl5f96" name="Step 3 - ${sys.systemName}" camunda:formKey="embedded:app:forms/dd-display-form.html" camunda:candidateGroups="MetadataScanningTeam" camunda:dueDate="P1W">
<bpmn:incoming>SequenceFlow_0awtesr</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1f0yvsl</bpmn:outgoing>
</bpmn:userTask>
</bpmn:subProcess>
<bpmn:sequenceFlow id="SequenceFlow_1n4omi3" sourceRef="Task_1kw6h8b" targetRef="SubProcess_16ii7vk" />
<bpmn:endEvent id="EndEvent_1hb267s">
<bpmn:incoming>SequenceFlow_0u0dpn4</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_0u0dpn4" sourceRef="SubProcess_16ii7vk" targetRef="EndEvent_1hb267s" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="camunda-test">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="156" y="103" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1war6r2_di" bpmnElement="SequenceFlow_1war6r2">
<di:waypoint x="192" y="121" />
<di:waypoint x="242" y="121" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="UserTask_0mh1ecs_di" bpmnElement="Task_1kw6h8b">
<dc:Bounds x="242" y="81" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="SubProcess_16ii7vk_di" bpmnElement="SubProcess_16ii7vk" isExpanded="true">
<dc:Bounds x="270" y="326" width="551" height="200" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="StartEvent_0hmj9us_di" bpmnElement="StartEvent_0hmj9us">
<dc:Bounds x="299" y="400" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0k9gw4m_di" bpmnElement="SequenceFlow_0k9gw4m">
<di:waypoint x="335" y="418" />
<di:waypoint x="385" y="418" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0awtesr_di" bpmnElement="SequenceFlow_0awtesr">
<di:waypoint x="485" y="418" />
<di:waypoint x="535" y="418" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_1sgs88n_di" bpmnElement="EndEvent_1sgs88n">
<dc:Bounds x="685" y="400" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1f0yvsl_di" bpmnElement="SequenceFlow_1f0yvsl">
<di:waypoint x="635" y="418" />
<di:waypoint x="685" y="418" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1n4omi3_di" bpmnElement="SequenceFlow_1n4omi3">
<di:waypoint x="292" y="161" />
<di:waypoint x="292" y="244" />
<di:waypoint x="546" y="244" />
<di:waypoint x="546" y="326" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_1hb267s_di" bpmnElement="EndEvent_1hb267s">
<dc:Bounds x="871" y="408" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0u0dpn4_di" bpmnElement="SequenceFlow_0u0dpn4">
<di:waypoint x="821" y="426" />
<di:waypoint x="871" y="426" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="UserTask_063tw82_di" bpmnElement="Task_0zfgdnv">
<dc:Bounds x="385" y="378" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="UserTask_01eg16s_di" bpmnElement="Task_0fl5f96">
<dc:Bounds x="535" y="378" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Can someone help me on how to deserialize the task variable in embedded form or am i missing something here?
Any help is much appreciated.