AnsweredAssumed Answered

Assignee cannot be updated with updateTask in Java

Question asked by joko71 on Oct 1, 2010
Latest reply on Jul 11, 2017 by java
snippet from workflow model:

      <type name="sdzwf:someTask">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageActionGroup">
               <default>add_package_item_actions</default>
            </property>
            <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
            </property>
         </overrides>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>

snippet from workflow definition:

   <swimlane name="somelane">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{bpm_assignee}</actor>
      </assignment>
   </swimlane>                  
 


   <task-node name="someTask">
      <task name="sdzwf:someTask" swimlane="somelane"></task>
      <transition to="someTask1" name="Odobri"></transition>
      <transition to="someTask2" name="Vrati"></transition>
   </task-node>

snippet from java code:

      TransactionService transactionService = AlfrescoServices.getTransactionService();
      RetryingTransactionCallback<Object> work = new RetryingTransactionCallback<Object>() {

         public Object execute() throws Throwable {
            
            NodeRef nrUser = Authentication.getInstance().getUserNodeRef(ticket);
            
            WorkflowTask task = AlfrescoServices.getWorkflowService().getTaskById(taskId);
            String pathId = task.path.id;
            
            // update map
            Map<QName, Serializable> updateProperties = new HashMap<QName, Serializable>();
            
             // assignee node reference
             NodeRef nrAssignee = AlfrescoServices.getPersonService().getPerson(assigneeUsername);

             if(nrAssignee != null) {

                updateProperties.put(WorkflowModel.ASSOC_ASSIGNEE, nrAssignee);
               
                // update task
                AlfrescoServices.getWorkflowService().updateTask(taskId, updateProperties, null, null);
               
                // execute task
               WorkflowPath path = AlfrescoServices.getWorkflowService().signal(pathId, transitionId);
             }

            return null;
         }
      };
      
      transactionService.getRetryingTransactionHelper().doInTransaction(work);

Problem is that updateTask method does not update bpm:assignee property in HashMap which task object holds, the old value from previous task persists. What must I change within my code for this to work?

Oh yes, I'm working with Alfresco 2.1 … :)

Outcomes