cancel
Showing results for 
Search instead for 
Did you mean: 

Email reviewers on parallel review workflow

ph73nt
Champ in-the-making
Champ in-the-making
Dear forum

I edited the sample parallel review workflow in an attempt to email reviewers on initiation. I've been able to do something similar (by searching this forum) for the parallel group review and the adhoc task, but not this one. I'm suspicious that the problem is to do with the way I use bpm_assignees in my start-state:

<swimlane name="initiator" />

    <start-state name="start">
      <task name="wf:submitParallelReviewTask" swimlane="initiator" />
      <transition name="" to="startreview">
        <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
          <script>
            for(var i=0; i &lt; bpm_assignees.length; i++ )
            {
               var mail = actions.create("mail");
               mail.parameters.to = bpm_assignees[i].properties.email;
               mail.parameters.subject = "Document for approval";
               mail.parameters.from = initiator.properties.email;
               mail.parameters.text = initiator.properties.firstName + " "
                         + initiator.properties.lastName
                         + " has requested a document review: "
                         + "\u000D\u000D"
                         + bpm_workflowDescription
                         + "\u000D\u000D"
                         + "Log on to Alfresco here: http://10.136.1.176:8080/share";
               mail.execute(bpm_package);
            }
          </script>
        </action>
      </transition>
    </start-state>

Hoping for more help…. thanks, Neil
7 REPLIES 7

isloat
Champ in-the-making
Champ in-the-making
Hi,
I use the e-mail notification in another node. Not the start-task one:

 <start-state name="start">
      <task name="wf:submitParallelReviewTask" swimlane="initiator" />
      <transition name="" to="startreview" />
   </start-state>

   <node name="startreview">
        <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
            <foreach>#{bpm_assignees}</foreach>
            <var>user</var>
        </action>
        <transition name="transName" to="dosomething">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
          <script>
         var mail = actions.create("mail");
         mail.parameters.to = user.properties.email;
         mail.parameters.subject ="Document for approval";
         mail.parameters.from = initiator.properties.email;
         mail.parameters.text =  mail.parameters.text = initiator.properties.firstName + " "
                         + initiator.properties.lastName
                         + " has requested a document review: "
                         + "\u000D\u000D"
                         + bpm_workflowDescription
                         + "\u000D\u000D"
                         + "Log on to Alfresco here: http://10.136.1.176:8080/share";
         mail.execute(bpm_package);
          </script>
      </action>
   </transition>
   </node>

It works in my WF.

Good luck!

ph73nt
Champ in-the-making
Champ in-the-making
Good method, thanks, Neil

mthomas
Champ in-the-making
Champ in-the-making
This isn't working for me.  The email gets sent but I the task isn't created for the assigned user.  I recieve an error, "org.alfresco.service.cmr.workflow.WorkflowException: 00300001 Failed to signal transition null from workflow task jbpm$609."

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

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

    <swimlane name="initiator" />

    <start-state name="start">
        <task name="wf:submitParallelReviewTask" swimlane="initiator" />
        <transition name="" to="startreview"/>
    </start-state>

    <node name="startreview">
        <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
            <foreach>#{bpm_assignees}</foreach>
            <var>reviewer</var>
        </action>
   <transition name="transName" to="dosomething">
   <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
   <runas>admin</runas>
           <script>
                var mail = actions.create("mail");
                mail.parameters.to = reviewer.properties.email;
                mail.parameters.subject ="Document for your review";
            mail.parameters.from = initiator.properties.email;
            mail.parameters.text =  mail.parameters.text = initiator.properties.firstName + " "
                         + initiator.properties.lastName
                         + " has requested a document review: "
                         + "\u000D\u000D"
                         + bpm_workflowDescription
                         + "\u000D\u000D"
                         + "Log on to Share here: ";
            mail.execute(bpm_package);
           </script>
         </action>
   </transition>        
        <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">
            <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="approve" to="endreview">
            <script>
                <variable name="wf_approveCount" access="read,write" />
                <expression>
                    wf_approveCount = wf_approveCount +1;
                 </expression>
            </script>
        </transition>
        <transition name="reject" to="endreview" />
    </task-node>

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

    <decision name="isapproved">
        <event type="node-enter">
           <script>
              <variable name="wf_reviewerCount" access="write"/>
              <variable name="wf_requiredPercent" access="write"/>
              <variable name="wf_actualPercent" access="write"/>
              <expression>
                  wf_requiredPercent = wf_requiredApprovePercent;
                  wf_reviewerCount = bpm_assignees.size();
                  wf_actualPercent = ((wf_approveCount * 100) / wf_reviewerCount);
              </expression>
           </script>
        </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>

ph73nt
Champ in-the-making
Champ in-the-making
Hi

Your "doSomething" transition doesn't do anything - but it has to go somewhere (hence transition null). I use transition to="review." Here's my whole process definition:


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

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

    <swimlane name="initiator" />

    <start-state name="start">
      <task name="wf:submitParallelReviewTask" swimlane="initiator" />
      <transition name="" to="startreview" />
   </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">
        <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var mail = actions.create("mail");
               mail.parameters.to = reviewer.properties.email;
               mail.parameters.subject ="Document for approval";
               mail.parameters.from = initiator.properties.email;
               mail.parameters.text =  mail.parameters.text = initiator.properties.firstName + " "
                               + initiator.properties.lastName
                               + " has requested a document review: "
                               + "\u000D\u000D"
                               + bpm_workflowDescription
                               + "\u000D\u000D"
                               + "Log on to Alfresco here: http://10.136.1.176:8080/share";
               mail.execute(bpm_package);
            </script>
        </action>
     </transition>
   </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="approve" to="endreview">
          <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
              <variable name="wf_approveCount" access="read,write" />
                <expression>
                    wf_approveCount = wf_approveCount +1;
                 </expression>
            </script>
         </action>
            <script>

            </script>
        </transition>
        <transition name="reject" to="endreview" />
    </task-node>

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

    <decision name="isapproved">
        <event type="node-enter">
           <script>
              <variable name="wf_reviewerCount" access="write"/>
              <variable name="wf_requiredPercent" access="write"/>
              <variable name="wf_actualPercent" access="write"/>
              <expression>
                  wf_requiredPercent = wf_requiredApprovePercent;
                  wf_reviewerCount = bpm_assignees.size();
                  wf_actualPercent = ((wf_approveCount * 100) / wf_reviewerCount);
              </expression>
           </script>
        </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>

Hope this helps and I hope I haven't left my email address in it (again). I found that process definitions started to make sense when I installed the Eclipse plugin (as in the wiki workflow page) as you get to draw yourself a process map first and then fill in the extra details later (like swimlane, scripts etc) so transitions take care of themselves.

Neil

mthomas
Champ in-the-making
Champ in-the-making
That does help, THANKS!
I also found that I could place the script in the "task-create" event.
My next attempt is to send an email notification when the task is reassigned.  Do you know which file I edit to add the email script to the "reassign" button?

-Michael

ph73nt
Champ in-the-making
Champ in-the-making
I'm afraid not; I haven't yet got that far. I'd like to know the answer, though 🙂

mthomas
Champ in-the-making
Champ in-the-making
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.