AnsweredAssumed Answered

Setting task variables from Java

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

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:

   <type name="my:task">
         <property name="my:status">
            <title>My status</title>

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>
         <variable name="my_status"/>

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");
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 ?