cancel
Showing results for 
Search instead for 
Did you mean: 

Set workflow task property before displaying it in UI

alar
Champ in-the-making
Champ in-the-making
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.)
2 REPLIES 2

jayjayecl
Confirmed Champ
Confirmed Champ
Hi, I found a solution to this right there :

http://forums.alfresco.com/en/viewtopic.php?f=34&t=17310

alar
Champ in-the-making
Champ in-the-making
Thanks, it worked. I was able to set it this way:


<task-node name="review">
   <task name="wf:reviewTask" swimlane="reviewer" />
   <event type="task-create">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
            taskInstance.setVariable('bpm_assignee', people.getPerson('username').nodeRef);
         </script>
      </action>
   </event>
</task-node>