cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow updating document properties

crono40
Champ on-the-rise
Champ on-the-rise
Hello,

I have a question. I want to use the advanced workflow "Send Documents for review (Request document approval from one or more colleagues)".

When I put the document in my folder, i set a value to the document description (draft).

I would like to update this value, when i start a workflow on this document.

Finally, I would like to update it again when the workflow is validated.

Is there a way to do it easily ?

Thanks for yours answers.
12 REPLIES 12

lementree
Champ on-the-rise
Champ on-the-rise
Hi,

you can do this, for this you need to add logic in activiti bpmn file.

On statrt workflow you can change the status to like "In Review"
After approve you can change the staus to "Approved"


<process id="<id>" name="<name>">

        <extensionElements>
            <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
              <activiti:field name="script">
                     <activiti:string>
                          for(var j=0; j&lt;bpm_package.children.length; j++){
            bpm_package.children[j].properties["preifx:status"]="In Review";
            bpm_package.children[j].save();
         }
                     </activiti:string>
                  </activiti:field>
            </activiti:executionListener>
        </extensionElements>

   <userTask id="<id>" name="<name>" activiti:formKey="<formKey>">
    <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if(task.getVariableLocal('reviewBNOutcome') == 'Approve') {
                           for(var j=0; j&lt;bpm_package.children.length; j++){
               bpm_package.children[j].properties["preifx:status"]="Approved";
               bpm_package.children[j].save();
            }
                        }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
           </extensionElements>
   </userTask>

crono40
Champ on-the-rise
Champ on-the-rise
Hi,

Thanks for your answer lementree. Could you tell me which file I have to update for this ? I suppose it is adhoc.bpmn20.xml located in \tomcat\webapps\alfresco\WEB-INF\classes\alfresco\workflow.

Waiting for your answer.

lementree
Champ on-the-rise
Champ on-the-rise
Yes, and after modifing you need to make change in tomcat\webapps\alfresco\WEB-INF\classes\alfresco\bootstrap-context.xml to re-deploy the workflow.

crono40
Champ on-the-rise
Champ on-the-rise
I modified my adhoc.bpmn20.xml file. I have now :



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

<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn"
   xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
   xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema"
   expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://alfresco.org">

    <process isExecutable="true" id="activitiAdhoc" name="Adhoc Activiti Process">

        <startEvent id="start"
            activiti:formKey="wf:submitAdhocTask" />
        <sequenceFlow id='flow1'
            sourceRef='start'
            targetRef='adhocTask' />

        <userTask id="adhocTask" name="Adhoc Task"
            activiti:formKey="wf:adhocTask">
           <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                      if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                      if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
           </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${bpm_assignee.properties.userName}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>

        <sequenceFlow id='flow2'
        sourceRef='adhocTask'
            targetRef='verifyTaskDone' />

        <userTask id="verifyTaskDone" name="Verify Adhoc Task Completed."
            activiti:formKey="wf:completedAdhocTask" >
            <documentation>
                Verify the task was completed.
            </documentation>
            <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                       
                        if (wf_notifyMe)
                     {
                        var mail = actions.create("mail");
                        mail.parameters.to = initiator.properties.email;
                        mail.parameters.subject = "Adhoc Task " + bpm_workflowDescription;
                        mail.parameters.from = bpm_assignee.properties.email;
                        mail.parameters.text = "It's done";
                        mail.execute(bpm_package);
                     }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
           </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${initiator.exists() ? initiator.properties.userName : 'admin'}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>

        <sequenceFlow id='flow3' sourceRef='verifyTaskDone'
            targetRef='theEnd' />

        <endEvent id="theEnd" />

   </process>
  
   <process id="WorkflowDesc" name="Workflow Description">

        <extensionElements>
            <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
              <activiti:field name="script">
                     <activiti:string>
                          for(var j=0; j&lt;bpm_package.children.length; j++){
            bpm_package.children[j].properties["preifx:status"]="In Review";
            bpm_package.children[j].save();
         }
                     </activiti:string>
                  </activiti:field>
            </activiti:executionListener>
        </extensionElements>

   <userTask id="TaskDesc" name="Task Desc" activiti:formKey="wf:completedAdhocTask">
   <extensionElements>
    <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if(task.getVariableLocal('reviewBNOutcome') == 'Approve') {
                           for(var j=0; j&lt;bpm_package.children.length; j++){
               bpm_package.children[j].properties["preifx:status"]="Approved";
               bpm_package.children[j].save();
            }
                        }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
    </extensionElements>
   </userTask>
   </process>

   <!– Graphical representaion of diagram –>
   <bpmndi:BPMNDiagram id="BPMNDiagram_activitiAdhoc">
      <bpmndi:BPMNPlane bpmnElement="activitiAdhoc" id="BPMNPlane_activitiAdhoc">
         <bpmndi:BPMNShape bpmnElement="start"
            id="BPMNShape_start">
            <omgdc:Bounds height="35" width="35" x="30" y="200"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="adhocTask"
            id="BPMNShape_adhocTask">
            <omgdc:Bounds height="55" width="105" x="130"
               y="190"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="verifyTaskDone"
            id="BPMNShape_verifyTaskDone">
            <omgdc:Bounds height="55" width="105" x="290"
               y="190"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="theEnd"
            id="BPMNShape_theEnd">
            <omgdc:Bounds height="35" width="35" x="455" y="200"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
            <omgdi:waypoint x="65" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="130" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
            <omgdi:waypoint x="235" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="290" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
            <omgdi:waypoint x="395" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="455" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
      </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>

</definitions>


But it's still not working. Could you tell me what I have to update in the bootstrap-context.xml ? I suppose it's in the
<bean id="workflowBootstrap" parent="workflowDeployer">


Maybe this one ?

<!– Activiti Review workflow definition –>
                <props>
                    <prop key="engineId">activiti</prop>
                    <prop key="location">alfresco/workflow/review.bpmn20.xml</prop>
                    <prop key="mimetype">text/xml</prop>
                    <prop key="redeploy">false</prop>
                </props>

What I have to do next ?

lementree
Champ on-the-rise
Champ on-the-rise
Hi,

I gave you just example code, you need to replace that with your contentmodel and properties.
Do you have knowledge in Activiti workflow?.


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

<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn"
   xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
   xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema"
   expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://alfresco.org">

    <process isExecutable="true" id="activitiAdhoc" name="Adhoc Activiti Process">

        <startEvent id="start"
            activiti:formKey="wf:submitAdhocTask" />
        <extensionElements>
            <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
              <activiti:field name="script">
                     <activiti:string>
                          for(var j=0; j&lt;bpm_package.children.length; j++){
            bpm_package.children[j].properties["<customStatusProperty>"]="In Review";
            bpm_package.children[j].save();
         }
                     </activiti:string>
                  </activiti:field>
            </activiti:executionListener>
        </extensionElements>
        <sequenceFlow id='flow1'
            sourceRef='start'
            targetRef='adhocTask' />

        <userTask id="adhocTask" name="Adhoc Task"
            activiti:formKey="wf:adhocTask">
           <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                      if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                      if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
           </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${bpm_assignee.properties.userName}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>

        <sequenceFlow id='flow2'
        sourceRef='adhocTask'
            targetRef='verifyTaskDone' />

        <userTask id="verifyTaskDone" name="Verify Adhoc Task Completed."
            activiti:formKey="wf:completedAdhocTask" >
            <documentation>
                Verify the task was completed.
            </documentation>
            <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;

                        if (wf_notifyMe)
                     {
                        var mail = actions.create("mail");
                        mail.parameters.to = initiator.properties.email;
                        mail.parameters.subject = "Adhoc Task " + bpm_workflowDescription;
                        mail.parameters.from = bpm_assignee.properties.email;
                        mail.parameters.text = "It's done";
                        mail.execute(bpm_package);
                     }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
               <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                           for(var j=0; j&lt;bpm_package.children.length; j++){
               bpm_package.children[j].properties["<customStatusProperty>"]="Approved";
               bpm_package.children[j].save();
            }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
    </extensionElements>
           </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${initiator.exists() ? initiator.properties.userName : 'admin'}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>

        <sequenceFlow id='flow3' sourceRef='verifyTaskDone'
            targetRef='theEnd' />

        <endEvent id="theEnd" />

   </process>

 

   <!– Graphical representaion of diagram –>
   <bpmndi:BPMNDiagram id="BPMNDiagram_activitiAdhoc">
      <bpmndi:BPMNPlane bpmnElement="activitiAdhoc" id="BPMNPlane_activitiAdhoc">
         <bpmndi:BPMNShape bpmnElement="start"
            id="BPMNShape_start">
            <omgdc:Bounds height="35" width="35" x="30" y="200"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="adhocTask"
            id="BPMNShape_adhocTask">
            <omgdc:Bounds height="55" width="105" x="130"
               y="190"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="verifyTaskDone"
            id="BPMNShape_verifyTaskDone">
            <omgdc:Bounds height="55" width="105" x="290"
               y="190"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="theEnd"
            id="BPMNShape_theEnd">
            <omgdc:Bounds height="35" width="35" x="455" y="200"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
            <omgdi:waypoint x="65" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="130" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
            <omgdi:waypoint x="235" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="290" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
            <omgdi:waypoint x="395" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="455" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
      </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>

</definitions>

In the above replace
<customStatusProprty>
with your custom model property or some property to save the status.


In the bootstrap-context.xml file you need to make
<prop key="redeploy">true</prop>
in corrresponding bpmn20.xml entry i.e

                <props>

                    <prop key="engineId">activiti</prop>

                    <prop key="location">alfresco/workflow/adhoc.bpmn20.xml</prop>

                    <prop key="mimetype">text/xml</prop>

                    <prop key="redeploy">false</prop>

                </props>

crono40
Champ on-the-rise
Champ on-the-rise
I updated the file adhoc.bpm20.xml. Here, the file content :

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

<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn"
   xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
   xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema"
   expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://alfresco.org">

    <process isExecutable="true" id="activitiAdhoc" name="Adhoc Activiti Process">

        <startEvent id="start"
            activiti:formKey="wf:submitAdhocTask" />
        <sequenceFlow id='flow1'
            sourceRef='start'
            targetRef='adhocTask' />

        <userTask id="adhocTask" name="Adhoc Task"
            activiti:formKey="wf:adhocTask">
           <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                      if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                      if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
           </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${bpm_assignee.properties.userName}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>

        <sequenceFlow id='flow2'
        sourceRef='adhocTask'
            targetRef='verifyTaskDone' />

        <userTask id="verifyTaskDone" name="Verify Adhoc Task Completed."
            activiti:formKey="wf:completedAdhocTask" >
            <documentation>
                Verify the task was completed.
            </documentation>
            <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                       
                        if (wf_notifyMe)
                     {
                        var mail = actions.create("mail");
                        mail.parameters.to = initiator.properties.email;
                        mail.parameters.subject = "Adhoc Task " + bpm_workflowDescription;
                        mail.parameters.from = bpm_assignee.properties.email;
                        mail.parameters.text = "It's done";
                        mail.execute(bpm_package);
                     }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
           </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${initiator.exists() ? initiator.properties.userName : 'admin'}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>

        <sequenceFlow id='flow3' sourceRef='verifyTaskDone'
            targetRef='theEnd' />

        <endEvent id="theEnd" />

   </process>
  
   <process id="WorkflowDesc" name="Workflow Description">

        <extensionElements>
            <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
              <activiti:field name="script">
                     <activiti:string>
                          for(var j=0; j&lt;bpm_package.children.length; j++){
            bpm_package.children[j].properties["preifx:status"]="In Review";
            bpm_package.children[j].save();
         }
                     </activiti:string>
                  </activiti:field>
            </activiti:executionListener>
        </extensionElements>

   <userTask id="TaskDesc" name="Task Desc" activiti:formKey="wf:completedAdhocTask">
   <extensionElements>
    <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if(task.getVariableLocal('reviewBNOutcome') == 'Approve') {
                           for(var j=0; j&lt;bpm_package.children.length; j++){
               bpm_package.children[j].properties["preifx:status"]="Approved";
               bpm_package.children[j].save();
            }
                        }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
    </extensionElements>
   </userTask>
   </process>

   <!– Graphical representaion of diagram –>
   <bpmndi:BPMNDiagram id="BPMNDiagram_activitiAdhoc">
      <bpmndi:BPMNPlane bpmnElement="activitiAdhoc" id="BPMNPlane_activitiAdhoc">
         <bpmndi:BPMNShape bpmnElement="start"
            id="BPMNShape_start">
            <omgdc:Bounds height="35" width="35" x="30" y="200"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="adhocTask"
            id="BPMNShape_adhocTask">
            <omgdc:Bounds height="55" width="105" x="130"
               y="190"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="verifyTaskDone"
            id="BPMNShape_verifyTaskDone">
            <omgdc:Bounds height="55" width="105" x="290"
               y="190"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="theEnd"
            id="BPMNShape_theEnd">
            <omgdc:Bounds height="35" width="35" x="455" y="200"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
            <omgdi:waypoint x="65" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="130" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
            <omgdi:waypoint x="235" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="290" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
            <omgdi:waypoint x="395" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="455" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
      </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>

</definitions>


When i start the workflow, the file description is not updated. Could you tell me What I have to update in bootstrap-context.xml ? I suppose it's this part :


<!– Activiti Parallel Review workflow definition –>
                <props>
                    <prop key="engineId">activiti</prop>
                    <prop key="location">alfresco/workflow/parallel-review.bpmn20.xml</prop>
                    <prop key="mimetype">text/xml</prop>
                    <prop key="redeploy">true</prop>
                </props>
               

lementree
Champ on-the-rise
Champ on-the-rise
Hi,

I gave you just example code, you need to replace that with your contentmodel and properties.
Do you have knowledge in Activiti workflow?.


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

<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn"
   xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
   xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema"
   expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://alfresco.org">

    <process isExecutable="true" id="activitiAdhoc" name="Adhoc Activiti Process">

        <startEvent id="start"
            activiti:formKey="wf:submitAdhocTask" />
        <extensionElements>
            <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
              <activiti:field name="script">
                     <activiti:string>
                          for(var j=0; j&lt;bpm_package.children.length; j++){
            bpm_package.children[j].properties["<customStatusProperty>"]="In Review";
            bpm_package.children[j].save();
         }
                     </activiti:string>
                  </activiti:field>
            </activiti:executionListener>
        </extensionElements>
        <sequenceFlow id='flow1'
            sourceRef='start'
            targetRef='adhocTask' />

        <userTask id="adhocTask" name="Adhoc Task"
            activiti:formKey="wf:adhocTask">
           <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                      if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                      if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
           </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${bpm_assignee.properties.userName}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>

        <sequenceFlow id='flow2'
        sourceRef='adhocTask'
            targetRef='verifyTaskDone' />

        <userTask id="verifyTaskDone" name="Verify Adhoc Task Completed."
            activiti:formKey="wf:completedAdhocTask" >
            <documentation>
                Verify the task was completed.
            </documentation>
            <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;

                        if (wf_notifyMe)
                     {
                        var mail = actions.create("mail");
                        mail.parameters.to = initiator.properties.email;
                        mail.parameters.subject = "Adhoc Task " + bpm_workflowDescription;
                        mail.parameters.from = bpm_assignee.properties.email;
                        mail.parameters.text = "It's done";
                        mail.execute(bpm_package);
                     }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
               <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                           for(var j=0; j&lt;bpm_package.children.length; j++){
               bpm_package.children[j].properties["<customStatusProperty>"]="Approved";
               bpm_package.children[j].save();
            }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
    </extensionElements>
           </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${initiator.exists() ? initiator.properties.userName : 'admin'}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>

        <sequenceFlow id='flow3' sourceRef='verifyTaskDone'
            targetRef='theEnd' />

        <endEvent id="theEnd" />

   </process>

 

   <!– Graphical representaion of diagram –>
   <bpmndi:BPMNDiagram id="BPMNDiagram_activitiAdhoc">
      <bpmndi:BPMNPlane bpmnElement="activitiAdhoc" id="BPMNPlane_activitiAdhoc">
         <bpmndi:BPMNShape bpmnElement="start"
            id="BPMNShape_start">
            <omgdc:Bounds height="35" width="35" x="30" y="200"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="adhocTask"
            id="BPMNShape_adhocTask">
            <omgdc:Bounds height="55" width="105" x="130"
               y="190"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="verifyTaskDone"
            id="BPMNShape_verifyTaskDone">
            <omgdc:Bounds height="55" width="105" x="290"
               y="190"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="theEnd"
            id="BPMNShape_theEnd">
            <omgdc:Bounds height="35" width="35" x="455" y="200"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
            <omgdi:waypoint x="65" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="130" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
            <omgdi:waypoint x="235" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="290" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
            <omgdi:waypoint x="395" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="455" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
      </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>

</definitions>

In the above replace
<customStatusProprty>
with your custom model property or some property to save the status.


In the bootstrap-context.xml file you need to make
<prop key="redeploy">true</prop>
in corrresponding bpmn20.xml entry i.e

                <props>

                    <prop key="engineId">activiti</prop>

                    <prop key="location">alfresco/workflow/adhoc.bpmn20.xml</prop>

                    <prop key="mimetype">text/xml</prop>

                    <prop key="redeploy">false</prop>

                </props>

kaynezhang
World-Class Innovator
World-Class Innovator
You should redeploy the workflow definition,please visit http://localhost:8080/alfresco/faces/jsp/admin/workflow-console.jsp and execute redeploy command.

Ok. Thanks for your help. I succeeded doing it right. I had to modify the parallel-review.bpmn20.xml.

Here the first part of the file :

<process isExecutable="true" id="activitiParallelReview" name="Parallel Review And Approve Activiti Process">

        <extensionElements>
            <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
              <activiti:field name="script">
                     <activiti:string>
                          execution.setVariable('wf_approveCount', 0);
                        execution.setVariable('wf_rejectCount', 0);
                       
                        execution.setVariable('wf_actualPercent', 0);
                        execution.setVariable('wf_actualRejectPercent', 0);
                       
                          execution.setVariable('wf_reviewerCount', bpm_assignees.size());
                          execution.setVariable('wf_requiredPercent', wf_requiredApprovePercent);
                  
                  for(var j=0; j&lt;bpm_package.children.length; j++){
                     var doc = bpm_package.children[j];
                     doc.properties['cm:description'] = "EN COURS DE REVISION";
                     doc.save();
                  }
                  

                     </activiti:string>
                  </activiti:field>
            </activiti:executionListener>
        </extensionElements>


So now i've got an oter question. Is it possible at the same time, to create a new version of the document ?

Many thanks for your help, both of you.