AnsweredAssumed Answered

Add resource to a Workflow

Question asked by elessar on Nov 19, 2009
Hi!,

I'm interested in adding a file to a  workflow when it's going to finish. The Workflow is the next:

FolderA/FileA
Unprotect
FolderA/FileA
           /Copy of FileA
Start workflow on Copy of File A
…Workflow…
Press Button finish Workflow
<- Here Add the FileA resource
Finish Workflow
Protect FileA so Copy of FileA is destroyed.

In order to keep the workflow information, Id like to add to the workflow throw Javascript in the last phase the original document.
I've searched in google and I couldn't find the answer. Does anyone know it??

Here I add the workflow source, although I think is not very usefull in this case:

<?xml version="1.0" encoding="ISO-8859-1"?>

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:parallelreview">

    <swimlane name="initiator"></swimlane>
   <swimlane name="swimrevisar">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{bpm_assignee}</actor>
      </assignment>
   </swimlane>
   <swimlane name="swimaprobar">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{bpm_aprobador}</actor>
      </assignment>
   </swimlane>

    <start-state name="start">
        <task name="wf:submitParallelReviewTask" swimlane="initiator" />
        <transition name="" to="startreview"/>      
      <event type="node-leave">
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">            
               <script>               
            <expression>
            var dest = bpm_context.parent.childByNamePath("2.- En elaboración o modificación");             
            bpm_package.children[0].move(dest);      
            hijo = bpm_package.children[0];
            </expression>
               </script>
           </action>
       </event>
      
    </start-state>

    <node name="startreview">
        <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
            <foreach>#{bpm_assignees}</foreach>
            <var>reviewer</var>
        </action>
        <event type="node-enter">
            <script>
                <variable name="wf_approveCount" access="write" />
                <expression>               
                    wf_approveCount = 0;
            </expression>                                      
            </script>
        </event>
      
        <transition name="review" to="review" />      
    </node>

    <task-node name="review">
        <!– task name="wf:reviewTask"–>
      <task name="wf:idomEditar">
            <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
               <actor>#{reviewer}</actor>
            </assignment>
         <event type="task-create">
         <script>
            if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
            if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
         </script>
      </event>
        </task>
      
        <transition name="Editar" to="endreview">
            <script>
                <variable name="wf_approveCount" access="read,write" />
                <expression>
                    wf_approveCount = wf_approveCount +1;
                 </expression>
            </script>
        </transition>
    </task-node>

    <join name="endreview">
        <transition to="isapproved" />
    </join>

    <decision name="isapproved">
        <event type="node-enter">
           <script>
              <variable name="wf_reviewerCount" access="write"/>             
              <expression>                 
                  wf_reviewerCount = bpm_assignees.size();                 
              </expression>
           </script>
        </event>
       
        <transition name="approve" to="approved">
            <condition>#{wf_approveCount >= wf_reviewerCount}</condition>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">            
               <script>   
            <runas>admin</runas>
            <expression>
            var dest = bpm_context.parent.childByNamePath("3.- En revisión");             
            bpm_package.children[0].move(dest);                  
            </expression>
               </script>
           </action>
        </transition>
    </decision>
              
    <task-node name="approved" >
        <task name="wf:approvedParallelTask" swimlane="swimrevisar" >
          <event type="task-create">
         <script>
            if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
            if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
         </script>
         </event>
      </task>
        <transition name="Revisar" to="approved2" >
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">            
               <script>               
            <expression>
            var dest = bpm_context.parent.childByNamePath("4.- En aprobación");             
            bpm_package.children[0].move(dest);      
            hijo = bpm_package.children[0];
            </expression>
               </script>
           </action>       
      </transition>
      <transition name="Rechazar" to="startreview" >        
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">            
               <script>               
            <expression>
            var dest = bpm_context.parent.childByNamePath("2.- En elaboración o modificación");             
            bpm_package.children[0].move(dest);      
            hijo = bpm_package.children[0];
            </expression>
               </script>
           </action>       
       </transition>
    </task-node>
   
   <task-node name="approved2"  >
        <task name="wf:idomAprobar" swimlane="swimaprobar" >
         <event type="task-create">
         <script>
            if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
            if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
         </script>
         </event>
      </task>
        <transition name="Aprobar" to="approved3" >
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">            
               <script>               
            <expression>
            var dest = bpm_context.parent.childByNamePath("5.- Aprobado");             
            bpm_package.children[0].move(dest);      
            hijo = bpm_package.children[0];
            </expression>
               </script>
           </action>       
      </transition>
      <transition name="Rechazar" to="startreview" >        
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">            
               <script>               
            <expression>
            var dest = bpm_context.parent.childByNamePath("2.- En elaboración o modificación");             
            bpm_package.children[0].move(dest);      
            hijo = bpm_package.children[0];
            </expression>
               </script>
           </action>       
       </transition>
    </task-node>
   
   <task-node name="approved3"  >
       <task name="wf:idomFin" swimlane="initiator" />
       <transition name="Hecho" to="end" >
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">            
               <script>   
            
            <expression>
            var nRef = findNode(bpm_package.children[i].properties["cm:source"]);
            <!– Here Add nRef to workflow –>            
            </expression>
               </script>
           </action>       
       </transition>
   </task-node>

    <end-state name="end"/>

</process-definition>

Outcomes