cancel
Showing results for 
Search instead for 
Did you mean: 

Persisting model data between tasks in Alfresco

root
Champ in-the-making
Champ in-the-making
Hi All,

Is there a way to carry the task form data from one task to another?

- Using Activiti BPMN
- Alfresco Enterprise 4.1.3
- jBoss Server EAP5
- custom Model
- custom forms (37 fields)
- 6 transitions on the workflow

(start) -> Task 1 -> Task 2 -> Task 3 -> Task 4 -> Task 5 -> Task 6 -> (end)

Recommendations:

1) Use aspects and not Properties in your model.
2) Use execution.setVariable('x',task.getVariable('x'));

I am trying to do this the correct way. Are the above two options the only options or is there a better way that alfresco recommends?

Thanks in Advance,

root.
4 REPLIES 4

trademak
Star Contributor
Star Contributor
I don't know if I understand the question correctly. You should use task listeners with the complete and create events to copy variables. An example is a snippet from the the parallel-review.bpmn20.xml process definition:

<blockcode>
<userTask id="reviewTask" name="Review Task"
            activiti:formKey="wf:activitiReviewTask">
           <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
               <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if(task.getVariableLocal('wf_reviewOutcome') == 'Approve') {
                            var newApprovedCount = wf_approveCount + 1;
                          var newApprovedPercentage = (newApprovedCount / wf_reviewerCount) * 100;
                         
                          execution.setVariable('wf_approveCount', newApprovedCount);
                          execution.setVariable('wf_actualPercent', newApprovedPercentage);
                        } else {
                            var newRejectCount = wf_rejectCount + 1;
                            var newRejectPercentage = (newRejectCount / wf_reviewerCount) * 100;
                           
                            execution.setVariable('wf_rejectCount', newRejectCount);
                            execution.setVariable('wf_actualRejectPercent', newRejectPercentage);
                        }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
           </extensionElements>
</userTask>
</blockcode>

Is that what you are looking for?

Best regards,

root
Champ in-the-making
Champ in-the-making
Thank You for the answer and the example. I was afraid that would be the case for carrying the data between tasks and i was hopping that would be a simpler way, by passing an object (i.e task itself and override the next task with the previous task data) to maintain the state.

Gratefully,
/root

debarcar
Champ in-the-making
Champ in-the-making
I have relative question: is there global form attachs to the process but not only for the task?

Regards!

Debarcar

jbarrez
Star Contributor
Star Contributor
I don't understand what you mean with that. Could you elaborate?