activiti 7 how can we aasociate a task variable to User Task

Showing results for 
Search instead for 
Did you mean: 
Member II

activiti 7 how can we aasociate a task variable to User Task

We have a usecase where we need to set some custom metadata with the User Task to be created in the XML.

For eg. we need to insert a record in DB with 5-6 custom fields which are not stored in activiti as part of the Task instance. We have used two approaches

Approach 1:- We have tried associating task variables to user task in the XML as in activiti 6 but the variables are not getting associated with the task created by activiti.


 <bpmn2:userTask id="Task_0bmwliu" name="Part Installation">
      <bpmn2:dataObject id="taskId1" name="taskId1" itemSubjectRef="xsd:string">
      <bpmn2Smiley Surprisedutgoing>SequenceFlow_0kbqp3t</bpmn2Smiley Surprisedutgoing>

Approach 2:- We have implemented the Task Listener and tried to add the variable to that task but there is no provision in the API to add task variable to the Task Entity returned by TaskCreatedEvent. and there is no association in the XML.


else if (runtimeEvent instanceof TaskCreatedEvent) {
  "Do something, task is created: " + runtimeEvent.toString());
            TaskCreatedEvent taskEvent = (TaskCreatedEvent)runtimeEvent;
            Task task = taskEvent.getEntity();
            // get the metadata passed in to process instance as variable