cancel
Showing results for 
Search instead for 
Did you mean: 

[Solved]Can't Update Workflow Task Properties

min
Champ in-the-making
Champ in-the-making
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>
1 REPLY 1

min
Champ in-the-making
Champ in-the-making
This problem has been solved per http://forums.alfresco.com/en/viewtopic.php?f=34&t=22803

The property that I could not update had a default value set in the model.  Once I removed the default value, the property is updated correctly. 

While this solved the problem, I question whether this is proper behavior.  My assumption was that by the time the task-create event fires, that the properties had already received their default values.  In that I can read property values (e.g., taskId) in the task-create event, I assumed that other properties had already received their default values.  It would seem that the default values are assigned after the task-create event so therefore, the values I had set were overwritten.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.