cancel
Showing results for 
Search instead for 
Did you mean: 

Group Review & Approve Workflow Problem

grob
Champ in-the-making
Champ in-the-making
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/w...

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


Thanks for help!
7 REPLIES 7

adnangul
Champ in-the-making
Champ in-the-making
You can get task id as

taskInstance.id.

Regarding your email problem, have you configured the alfresco server rightly?

lucille_arkenst
Champ in-the-making
Champ in-the-making
You've got an extra </action> tag in node "startreview".
Once you fix that, you should start getting emails
(provided that your repository.properties file has been modified to send emails).
Hope this helps!

pp20218
Champ in-the-making
Champ in-the-making
Hi,

I have the same problem. Can anyone help me pls?

My process definition is

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

<process-definition  xmlns="urn:jbpm.org:jpdl-3.2"  name="wfSmiley Tonguearallelgroupreview">
<swimlane name="initiator"></swimlane>

   <start-state name="start">
      <task name="wf:submitGroupReviewTask"></task>
      <transition name="" to="startreview"></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>
        </event>
      <transition to="review" name="review"></transition>
   </node>

   <task-node name="review">
      <transition to="sendemail">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
       <script>
               var mail = actions.create("mail");
                     mail.parameters.to = bpm_assignee.properties.email;
                    mail.parameters.subject = "A document waiting for review " + bpm_workflowDescription;
                    mail.parameters.from = initiator.properties.email;
                    mail.parameters.text = "http://localhost:8080/alfresco/faces/jsp/login.jsp";
                    mail.execute(bpm_package);
              </script>
            </action>
</transition>
   </task-node>

   <task-node name="sendemail">
      <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"></transition>
   </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"></end-state>


</process-definition>

Pls help.

Thanks

pp20218
Champ in-the-making
Champ in-the-making
Can anyone help out pls?

lucille_arkenst
Champ in-the-making
Champ in-the-making
Check your logs; I've found information there to be helpful when debugging.
Where you have "<transition to="sendemail">" try using "<transition name="" to="sendemail">".  There is probably a reason why name is blank in the example parallelreview_group_processdefinition.xml.  It could be that the processor does not like it if you omit the "name" attribute.
Also, your <task-node name="review"> does not have a <task> in it and I think there should be.  Look closely at parallelreview_group_processdefinition.xml and/or adhoc_processdefinition.xml – these should help you.

pp20218
Champ in-the-making
Champ in-the-making
Thanx for your reply.

The same code worked for me.It was my mistake I didnt choose the right workflow from Alfresco while executing the workflow.

raghunandangowd
Confirmed Champ
Confirmed Champ

Hey,

What I should do to disable the Group and Pooled Review and Approve options from the drop-down menu.

In which file i should get that options to disable.

Thanks in advance,