AnsweredAssumed Answered

Group Review & Approve Workflow Problem

Question asked by grob on Feb 11, 2010
Latest reply on May 3, 2018 by raghunandangowda
Hi everyone!
I'm using Group Review & Approve Workflow on documents in alfresco. I assign a group of reviewers, who should approve or reject a specific document.
I would like to modify the out-of-the-box Workflow,  so that every reviewer gets an email when a new task is created and waiting….

First of all I would like to know if I'm modifying  the right process definition - parallelreview_group_processdefinition.xml.

I'm trying to send emails like this..

<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
     <script>
     var all_members = people.getMembers(bpm_groupAssignee);
   
     for(var i=0; i &lt; all_members.length; i++ )
     {
         var mail =  actions.create("mail");
         mail.parameters.to = all_members[i].properties.email;
         mail.parameters.subject = "New document is waiting";
         mail.parameters.from = "admin@alfresco.com";
         mail.parameters.text = "Some text";
              mail.execute(bpm_package);
   }
   </script>
</action>


Here is my process definition:

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

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

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

    <start-state name="start">
        <task name="wf:submitGroupReviewTask" swimlane="initiator" />
        <transition name="" to="startreview">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
            var all_members = people.getMembers(bpm_groupAssignee);
            
            for(var i=0; i &lt; all_members.length; i++ )
            {
               var mail =  actions.create("mail");
                mail.parameters.to = all_members[i].properties.email;
               mail.parameters.subject = "New document is waiting";
               mail.parameters.from = "admin@alfresco.com";
               mail.parameters.text = "Some text";
               mail.execute(bpm_package);
            }
              </script>
              </action>
   </transition>   
    </start-state>

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

    <task-node name="review">
        <task name="wf:reviewTask">
            <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="reject" to="endreview" />
        <transition name="approve" 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">
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <script>
                 <variable name="wf_reviewerCount" access="write"/>
                 <expression>people.getMembers(bpm_groupAssignee).length;</expression>
              </script>
           </action>
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <script>
                 <variable name="wf_requiredPercent" access="write"/>
                 <expression>wf_requiredPercent = wf_requiredApprovePercent;</expression>
              </script>
           </action>
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <script>
                 <variable name="wf_actualPercent" access="write"/>
                 <expression>wf_actualPercent = ((wf_approveCount * 100) / people.getMembers(bpm_groupAssignee).length);</expression>
              </script>
           </action>
        </event>
        <transition name="reject" to="rejected" />
   <transition name="approve" to="approved">
            <condition>#{wf_actualPercent >= wf_requiredApprovePercent}</condition>
        </transition>
    </decision>

    <task-node name="rejected">
        <task name="wf:rejectedParallelTask" swimlane="initiator" />
        <transition to="end" />
    </task-node>

    <task-node name="approved">
        <task name="wf:approvedParallelTask" swimlane="initiator" />
        <transition to="end" />
    </task-node>

    <end-state name="end"/>

</process-definition>
Am I doing something wrong, because no email is being sent?


And the secong thing:
I know that I can access a task directly via URL like this:
http://localhost:8080/alfresco/command/ui/managetask?id=jbpm$4&type={http://www.alfresco.org/model/workflow/1.0}adhocTask&container=plain

Does anyone know how to get a taskId in javascript in a Workflow, to send the link in email?


Thanks for help!

Outcomes