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,