cancel
Showing results for 
Search instead for 
Did you mean: 

how to send emails to users in parallel workflows?

giorgio
Champ in-the-making
Champ in-the-making
how to send an email to all users in parallel workflows?
Thanks
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
One way is to run a sendMail action as part of the workflow.

giorgio
Champ in-the-making
Champ in-the-making
Sorry, my question is not about email, is about permisions on documentos, here is the truth post

Hello good again and see if you can help me with this little problem, as I have discussed my job with eh managed workflows, specifically the review workflow, user to user, then once done, I've arranged to do the same but in the parallel flow of users, ie a user in to multiple users, and wonder if the code is the same, because in a work flow and the other not? in the two streams and send the mail perfectly task too, but in the workflow Parallel seems not remove the permissions, however, if I print in the mail the variable "acl" that contains the permissions that I removing, at the end if that contains the permissions that was supposed to wear.

processdefinition.xml you put two of each of the streams that you may see the differences:

This is the review_processdefinition.xml that if it works well, removes the permissions inheritance and assign new ones.

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

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

     <swimlane name="initiator" />

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

     <swimlane name="reviewer">
         <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
             <actor> # (bpm_assignee) </ actor>
         </ assignment>
     </ swimlane>

     <task-node name="review">
         <task name="wf:reviewTask" swimlane="reviewer">
             <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="" to="completed" />

     <event type="node-enter">
<! - Update the status to Rejected when we enter this task ->
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>



for (var i = 0, i <bpm_package.children.length i + +)
(

bpm_package.children [i]. properties [ "my: priority"] = bpm_workflowPriority;
bpm_package.children [i]. properties [ "my: ultimoestado"] = "Pendent";
bpm_package.children [i]. properties [ "my: ultimotecnico"] = bpm_assignee.properties [ "cm: userName"];
if (bpm_package.children [i]. properties [ "my: state"] == null) (
bpm_package.children [i]. properties [ "my: state"] = "Pendent";
bpm_package.children [i]. properties [ "my: tecnico"] = bpm_assignee.properties [ "cm: userName"];
) else (
bpm_package.children [i]. properties [ "my: state"] [bpm_package.children [i]. properties [ "my: state."] length] = "Pendent";
bpm_package.children [i]. properties [ "my: tecnico"] [bpm_package.children [i]. properties [ "my: tecnico."] length] = bpm_assignee.properties [ "cm: userName"];
)
bpm_package.children [i]. save ();


 

bpm_package.children [i]. setInheritsPermissions (false);

bpm_package.children var permissions = [i]. permissions;
var acl = [];
for (var j = 0, j <permissions.length j + +)
(
acl = permissions [j]. (";"); split
var perm = acl [2];
var grp = acl [1];
bpm_package.children [i]. removePermission (perm, grp);
)


bpm_package.children [i]. setPermission ( "Consumer" bpm_assignee.properties [ "cm: userName"]);



)

            var mail = actions.create ( "mail");
            bpm_assignee.properties mail.parameters.to = [ "cm: email"];
            mail.parameters.subject = "Notice of assignment" + bpm_workflowDescription;
            mail.parameters.from = "noreply@edu.gva.es";
            mail.parameters.text = "No reply to this task mensaje.La" + bpm_workflowDescription + "has been assigned must review here http://notasinternas.edu.gva.es";
            mail.execute (bpm_package);

</ script>
</ action>
</ event>

     </ task-node>

     <task-node name="completed">
     <event type="node-enter">
<! - Update the status to Rejected when we enter this task ->
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
for (var z = 0, z <bpm_package.children.length, z + +)
(

bpm_package.children [z]. properties [ "my: priority"] = bpm_workflowPriority;
bpm_package.children [z]. properties [ "my: ultimoestado"] = "acabat";
bpm_package.children [z]. properties [ "my: ultimotecnico"] = bpm_assignee.properties [ "cm: userName"];
if (bpm_package.children [z]. properties [ "my: state"] == null) (
bpm_package.children [z]. properties [ "my: state"] = "acabat";
bpm_package.children [z]. properties [ "my: tecnico"] = bpm_assignee.properties [ "cm: userName"];
) else (
bpm_package.children [z]. properties [ "my: state"] [bpm_package.children [z]. properties [ "my: state."] length] = "acabat";
bpm_package.children [z]. properties [ "my: tecnico"] [bpm_package.children [z]. properties [ "my: tecnico."] length] = bpm_assignee.properties [ "cm: userName"];
)
bpm_package.children [z]. save ();
)
</ script>
</ action>
</ event>
         <transition name="" to="end" />
     </ task-node>
     <end-state name="end" />

</ process-definition>


And this one is parallellreview_proccessdefinition.xml when the mail arrives but the task also reaches all users but it seems that does not cut the inheritance and does not assign new permissions to the document.

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

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

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

     <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" />
     </ node>

     <task-node name="review">
         <task name="wf:reviewTask">
             <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
                <actor> # (reviewer) </ actor>
             </ assignment>
         </ task>
<event type="node-enter">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>


for (var i = 0, i <bpm_package.children.length i + +)
(

bpm_package.children [i]. setInheritsPermissions (false);

bpm_package.children var permissions = [i]. permissions;
var acl = [];
for (var j = 0, j <permissions.length j + +)
(
acl = permissions [j]. (";"); split
var perm = acl [2];
var grp = acl [1];
bpm_package.children [i]. removePermission (perm, grp);

            var mail = actions.create ( "mail");
            reviewer.properties mail.parameters.to = [ "cm: email"];
            mail.parameters.subject = "Notice of assignment;
            mail.parameters.from = "noreply@edu.gva.es";
            mail.parameters.text = acl + "Do not respond to this mensaje.Tiene an assignment should review http://notasinternas.edu.gva.es here";
            mail.execute (bpm_package)

)

bpm_package.children [i]. setPermission ( "Coordinator", reviewer.properties [ "cm: userName"]);


)

            var mail = actions.create ( "mail");
            reviewer.properties mail.parameters.to = [ "cm: email"];
            mail.parameters.subject = "Notice of assignment;
            mail.parameters.from = "noreply@edu.gva.es";
            mail.parameters.text = acl + "Do not respond to this mensaje.Tiene an assignment should review http://notasinternas.edu.gva.es here";
            mail.execute (bpm_package);

</ script>
</ action>
</ event>
         <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">
            <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">
         <transition to="end" />
     </ task-node>

     <task-node name="approved">
         <transition to="end" />
     </ task-node>

     <end-state name="end"/>

</ process-definition>