AnsweredAssumed Answered

Setting task variables from Java

Question asked by fshipley on Nov 22, 2006
Latest reply on Dec 1, 2006 by davidc
Hi,

Can anyone tell me the "best" (recommended) way of updating task variables from Java ?

I have tried using both the jBPM TaskInstance.setVariable() and the Alfresco WorkflowService.updateTask() methods, however I am not getting the required result.

The property I need to update (my:status) is defined in my custom task model:

<types>
   <type name="my:task">
      <parent>bpm:workflowTask</parent>
      <properties>
         <property name="my:status">
            <title>My status</title>
            <type>d:text</type>
         </property>
      </properties>
   </type>
</types>

I define the property my_status in my process definition:

<task-node name="myTaskNode">
   <task name="my:task">
      <event type="task-end">
         <action name="task-end" class="my.repo.workflow.jbpm.TaskEndActionHandler" config-type="bean">
            <status>The End</status>
         </action>
      </event>
      <controller>
         <variable name="my_status"/>
      </controller>
   </task>
</task-node>

I would like to update the my_status (my:status) property from the Java class my.repo.workflow.jbpm.TaskEndActionHandler (in the example).

I have tried:
taskInstance.setVariable("my_status", "The End");
and
workflowService.updateTask(globalId, taskProps, null, null);

The taskInstance.setVariable() method seems to update the property OK, because if I do a taskInstance.getVariable() straight after, I get the correct value … however it gets set back to the old value somewhere else along the line.

Can anyone help ?

Thanks,
Frank

Outcomes