cancel
Showing results for 
Search instead for 
Did you mean: 

WCM Workflow - email notification to all the assignee

gianlucar
Champ in-the-making
Champ in-the-making
Hi All,
i modified the default "Serial Review" behavior changing the /tomcat/webapps/alfresco/WEB-INF/classes/alfresco/workflow/submit_processdefinition.xml file.

this is the code fragment:

           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
           <script>
          var mail = actions.create("mail");
          mail.parameters.to = bpm_assignees.get(0).properties.email;
          mail.parameters.subject = "Approve request"  + " from " + person.properties.userName;
          mail.parameters.from =   initiator.properties.email;
          mail.parameters.text =  "You are kindly requested to approve a content on Alfresco.\n\nDescrioption:\n" +  bpm_workflowDescription;
          mail.execute(bpm_package);

                 </script>

           </action>

Everything work fine but now i need to send the notification to all the assignee ,not just to the first ( bpm_assignees.get(0) ).
What i need to to change in order to send the notification to all the people assigneed to the workflow?

Thanks in advance
Gianluca
6 REPLIES 6

alejandrosl
Champ in-the-making
Champ in-the-making
Hi,

I think you have to insert the mail.parameters.to property into a for loop and add to it a new assignee email in every step, separating them by ;.


for (var i=0; i &lt; bpm_assignees.children.length; i++)
{
     mail.parameters.to += bpm_assignees.get(i).properties.email + "; ";
}

gianlucar
Champ in-the-making
Champ in-the-making
with this modification i get the following error:
15:37:28,270 ERROR [org.jbpm.jpdl.xml.JpdlXmlReader] couldn't parse process definition
org.dom4j.DocumentException: Error on line 107 of document  : The content of elements must consist of well-formed character data or markup. Nested exception: The content of elements must consist of well-formed character data or markup

actual code fragment:

<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                 <script>

          var mail = actions.create("mail");
          for (var i=0; i <= bpm_assignees.children.length; i++)
{
     mail.parameters.to += bpm_assignees.get(i).properties.email + "; ";
}

          mail.parameters.subject = "Approve request"  + " from " + person.properties.userName;
          mail.parameters.from =   initiator.properties.email;
          mail.parameters.text =  "You are kindly requested to approve a content on Alfresco.\n\nDescrioption:\n" +  bpm_workflowDescription;
          mail.execute(bpm_package);


                 </script>

           </action>

every way i know to do a loop generate an error 😞

alejandrosl
Champ in-the-making
Champ in-the-making
Not pretty sure, but I think it's because bpm_assignees variable definition is missing:

    <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                     <script>
              <variable name="bpm_package" access="read" />
              <variable name="bpm_assignees" access="read" />
              <expression>
              bpm_package.children[0].save();
              var mail = actions.create("mail");
              for (var i=0; i <= bpm_assignees.children.length; i++)
    {
         mail.parameters.to += bpm_assignees.get(i).properties.email + "; ";
    }

              mail.parameters.subject = "Approve request"  + " from " + person.properties.userName;
              mail.parameters.from =   initiator.properties.email;
              mail.parameters.text =  "You are kindly requested to approve a content on Alfresco.\n\nDescrioption:\n" +  bpm_workflowDescription;
              mail.execute(bpm_package);

              </expression>
                     </script>

               </action>

haroldvera
Champ in-the-making
Champ in-the-making
try this,

var mail = actions.create("mail");
        var revisores = [];
        for (var i=0; i < bpm_assignees.size(); i++){
            revisores.push(bpm_assignees.get(i).properties["cm:userName"]);
        }
        mail.parameters.to_many = revisores;
   mail.parameters.from="harold@pasionit.com";
   mail.parameters.subject="notificación: solicitud aprobación de crédito";
   mail.parameters.text="contenido por definir…";
   mail.execute(bpm_package);

wetry
Champ in-the-making
Champ in-the-making
or maybe '<' char is problematic as in this thread:
http://forums1.man.alfresco.com/en/viewtopic.php?f=34&t=10858
?

orggs
Champ in-the-making
Champ in-the-making
Is there some news on Alfresco 3.4d about this?