AnsweredAssumed Answered

Set workflow task property before displaying it in UI

Question asked by alar on Feb 5, 2009
Latest reply on Jun 12, 2009 by alar
Hi,

I have a very simple problem. I added a new property "wf:foo" to existing wf:reviewTask type in workflowModel.xml:


<type name="wf:reviewTask">
   <parent>bpm:workflowTask</parent>
   <properties>
      <property name="wf:foo">
         <type>d:text</type>
      </property>
   </properties>
</type>

I also added this property to the property-sheet description in web-client-config-properties.xml:


<config evaluator="node-type" condition="wf:reviewTask" replace="true">
   <property-sheet>
      <!– Existing properties omitted for example purpose –>
      <show-property name="wf:foo" display-label="Foo" />
   </property-sheet>
   </config>

I started a “Review & Approve” workflow and I could see the new Foo property field in “Review” task. If I entered a value and clicked Approve, then I could read the entered value in the task transition JavaScript like this (changed review_processdefinition.xml file):


<task-node name="review">
   <task name="wf:reviewTask" swimlane="reviewer" />
   <transition name="approve" to="approved">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
            logger.log("wf_foo=" + wf_foo);
         </script>
      </action>
   </transition>
   <transition name="reject" to="rejected" />
</task-node>

But the problem is that I wish to set the value of Foo property from JavaScript so the value could be displayed in the UI when Review task is opened. I tried doing it this way:


<task-node name="review">
   <event type="node-enter">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
            wf_foo = “bar”;
         </script>
      </action>
   </event>
   <task name="wf:reviewTask" swimlane="reviewer" />
   <transition name="approve" to="approved" />
   <transition name="reject" to="rejected" />
</task-node>

But it doesn't work, the “Foo” field is empty when I opened Review task. (I redeployed the workflow definition and also stared a new workflow, so the new code was in effect.) I also tried setting the value in “task-create” event inside the task node, but it didn't have any effect either.

So, my question is: is it possible to set the value of a workflow task property from JavaScript before it is displayed in the UI, and how is it done? (I am using Alfresco Labs 3 Stable.)

Outcomes