AnsweredAssumed Answered

Changing the bpm_assignee after workflow has started

Question asked by alouw on Feb 9, 2010
I am looking or a way of changing the bpm_assignee after a workflow has started.

In other words I assign the bpm_assignee to an Alfresco person when starting the workflow. One of the tasks in the workflow then need to change the bpm_assignee to a different Alfresco person, and the workflow should then go into that person's task list.

I have the following:

My processdefinition:

<<<<<
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="twflow:ChangeAssignee">

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

    <start-state name="start">
        <task name="twflow:firstTask" swimlane="initiator" />
        <transition name="First" to="middleNode" >
        </transition>
    </start-state>

    <task-node name="middleNode">
        <task name="twflow:middleTask" swimlane="currentAssignee" />
        <transition name="Reassign" to="reassignNode">
        </transition>
        <transition name="Finish" to="end">
        </transition>
    </task-node>

    <task-node name="reassignNode">
        <task name="twflow:reassignTask" swimlane="initiator"/>
        <transition name="Continue" to="middleNode">
        </transition>
    </task-node>

    <end-state name="end" />
   
</process-definition>
>>>>>

In my Model I declare each of the tasks as types. Each of these has the bpm:assignee as an aspect:

<<<<<
       <type name="twflow:firstTask">
         <title>First Task</title>
         <parent>bpm:startTask</parent>
         <mandatory-aspects>
           <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
       </type>
   
       <type name="twflow:middleTask">
         <title>Middle Task</title>
         <parent>bpm:workflowTask</parent>
         <mandatory-aspects>
           <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
       </type>
   
       <type name="twflow:reassignTask">
         <title>Reassign Task</title>
         <parent>bpm:workflowTask</parent>
         <mandatory-aspects>
           <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
       </type>
>>>>>>>>

In my web-client-config I make the bpm:assignee visible in all the tasks, and editable in the "reassignTask".

<<<<<<<<
<?xml version="1.0" encoding="UTF-8"?>
<alfresco-config>
  <config evaluator="node-type" condition="twflow:middleTask">
    <property-sheet>
      <show-association name="bpm:assignee" read-only="true" />
    </property-sheet>
  </config>  
  <config evaluator="node-type" condition="twflow:reassignTask">
    <property-sheet>
      <show-association name="bpm:assignee" />
    </property-sheet>
  </config>  
</alfresco-config>
>>>>>>>>

I now use Javascript to start the workflow, giving myself as the Alfresco person to use as the assignee.

<<<<<<<<
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$twflow:ChangeAssignee";
workflow.parameters["bpm:workflowDescription"] = "Test a Workflow";
workflow.parameters["bpm:assignee"] = people.getPerson("andre");
workflow.execute(document);
>>>>>>>>

With the workflow started and in my "todo list", in the first task I click on the "Reassign", this transitions to the "reassignNode" where I select a different Alfresco user as assignee. After doing this, looking at the workflow's variables in the workflow console it shows me that the bpm:assignee has changed and is pointing to the new Alfresco user (as selected).

But the "middleNode" task which started is still assigned to myself?

I am assuming this is related to process versus task variables, or something like that… But I am now seriously stumped and need some help around this.

Outcomes