AnsweredAssumed Answered

[Solved]Can't Update Workflow Task Properties

Question asked by min on Oct 15, 2009
Latest reply on Nov 1, 2009 by min
I am trying to update task properties with data captured from the previous task in the same workflow.  I've read all of the previous posts on this topic, but I am still having a problem.  Using Javascript taskInstance.setVariable("wf:someproperty", somevalue) in the task-create event of the second task I have successfully updated the property in the task model and it displayed in the workflow UI for the second task.  However, I am trying to update two properties, but only one property actually gets updated.  I confirmed the updates via the workflow console. The taskInstance statements are contained in the task-create event of the second task.  I can see via logger.log that the somevalue variables are populated prior to the setVariable.  The properties I am updating are part of a mandatory aspect attached to all of the tasks in the workflow.  The "requestShortDescription" property updates everytime and the "department" property never updates. 

As a test I removed constraints from the task model for the property that was not updating (department) thinking that this somehow was causing a problem, but this hasn't helped.  Has anyone experienced only some properties getting updated via taskInstance.setVariable?  Any suggestions? 


<process-definition  xmlns="urn:jbpm.org:jpdl-3.2"  name="ncwf:reviewapprovePurchaseRequest">

   <swimlane name="initiator"></swimlane>

   <start-state name="Start">
      <task name="ncwf:submitPurchaseRequestTask" swimlane="initiator"/>
      <transition to="InitiateRequest"></transition>
   
      <event type="task-end">
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <expression>
                  var requestShortDescription = taskInstance.getVariable("ncwf_requestShortDescription");
                  executionContext.setVariable("ncwf_requestShortDescription",requestShortDescription);
                  var department = taskInstance.getVariable("ncwf_department");
                  executionContext.setVariable("ncwf_department",department);
               </expression>
            </script>
         </action>
       </event>
   </start-state>
   
   <swimlane name="assignee">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{bpm_assignee}</actor>
      </assignment>
   </swimlane>

   <node name="InitiateRequest">
      <transition to="Review" name="toReview"></transition>
   </node>
   
   <task-node name="Review">
      <task name="ncwf:reviewPurchaseRequestTask" swimlane="assignee" /> 
      <transition to="Approved" name="toApproved">   </transition>
      <transition to="Rejected" name="toRejected">   </transition>
      
      <event type="task-create">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <expression>
                  var department=executionContext.getVariable("ncwf_department");
                  taskInstance.setVariable("ncwf:department", department);
                  var requestShortDescription=executionContext.getVariable("ncwf_requestShortDescription");
                  taskInstance.setVariable("ncwf:requestShortDescription", requestShortDescription);
               </expression>   
            </script>
         </action>   
      </event>      

   </task-node>

<?xml version="1.0" encoding="UTF-8"?>

<model name="ncwf:wfModelPurchaseRequest" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>Custom Workflow Model</description>
   <version>1.0</version>
   
   <imports>   
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />      
      <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm"/>
   </imports>         
   
   <namespaces>
      <namespace uri="http://www.alfresco.org/model/workflow/nc/1.0" prefix="ncwf"/>      
   </namespaces>      
   
   <types>   
      
      <!–  Basic Review & Approve Tasks –>              
      <!–                               –>   
      <type name="ncwf:submitPurchaseRequestTask">         
         <parent>bpm:startTask</parent>            
         
         <overrides>               
            <property name="bpm:packageActionGroup">                     
               <default>add_package_item_actions</default>               
            </property>
            <property name="bpm:packageItemActionGroup">                        
               <default>edit_package_item_actions</default>               
            </property>            
         </overrides>
         
         <mandatory-aspects>            
            <aspect>bpm:assignee</aspect>               
            <aspect>ncwf:requestData</aspect>             
         </mandatory-aspects>
      </type>
            
      <type name="ncwf:reviewPurchaseRequestTask">            
         <parent>bpm:workflowTask</parent>   

         <overrides>               
            <property name="bpm:packageItemActionGroup">                        
               <default>edit_package_item_actions</default>               
            </property>            
         </overrides>
         
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
            <aspect>ncwf:requestData</aspect>            
         </mandatory-aspects>   
   
      </type>      
   </types>               
      
      <aspects>
         <aspect name="ncwf:requestData">
            <properties>
               <property name="ncwf:requestShortDescription">
                  <type>d:text</type>
                  <mandatory>true</mandatory>
                  <default></default>
               </property>
               <property name="ncwf:department">
                  <type>d:text</type>
                  <mandatory>true</mandatory>
                  <default></default>
                  <constraints>
                     <constraint type="LIST">
                        <parameter name="allowedValues">
                           <list>
                              <value>Information Technology</value>
                              <value>Marketing</value>
                              <value>Sales</value>
                              <value>Finance</value>
                           </list>
                        </parameter>
                        <parameter name="caseSensitive"><value>true</value></parameter>
                     </constraint>
                  </constraints>
               </property>
               <property name="ncwf:approvedAmount">
                  <type>d:int</type>
                  <mandatory>false</mandatory>
                  <default>0</default>
                  <constraints>
                     <constraint type="MINMAX">
                        <parameter name="minValue"><value>0</value></parameter>
                        <parameter name="maxValue"><value>999999</value></parameter>
                     </constraint>
                  </constraints>
               </property>
            </properties>
         </aspect>
      </aspects>
</model>

Outcomes