cancel
Showing results for 
Search instead for 
Did you mean: 

Calling workflow assignee's e-mail in Javascript

hanoul
Champ in-the-making
Champ in-the-making
I have added e-mail notification to my Web Site Submission workflow (Enterprise version 3.1).
At the moment, I have the recipient's e-mail address hard coded in my script. However, I would like to have the e-mail sent to the next 'assignee' in a serial review. How can I call the next serial reviewer's (assignee) e-mail address in Javascript?

My code at present is the following, and is placed inside the 'submitserialreview' decision node inside <configRoot>/alfresco/workflow/submit-processdefinition.xml:

    <decision name="submitserialreview">
       <transition name="endreview" to="endreview" />
       <transition name="review" to="serialreview">
         <condition>#{wcmwf_approveCnt &lt; wcmwf_reviewerCnt}</condition>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <expression> 
               var mail = actions.create("mail");
               mail.parameters.to = "recipient_email@xxxx.com";
               mail.parameters.subject = "New Alfresco workflow submission: " + wcmwf_label + " by " + person.properties.userName;
               mail.parameters.from = initiator.properties["cm:email"];
               mail.parameters.text = person.properties.firstName + " " + person.properties.lastName + " has submitted the following content for your approval";
               mail.execute(bpm_package);               
               </expression>
            </script>
         </action>
       </transition>
    </decision>
10 REPLIES 10

tejaskanani2920
Champ in-the-making
Champ in-the-making
Hi,

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

Thanks

Try out below code it worked for me..


<decision name="submitserialreview">
      <transition name="endreview" to="endreview" />
      <transition name="review" to="serialreview">
         <condition>#{wcmwf_approveCnt &lt; wcmwf_reviewerCnt}</condition>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var mail = actions.create("mail");
               var to = "" ;
               var from = initiator.properties.email ;
               var subject = "Review content created by " + initiator.properties.userName ;
               if(bpm_assignees.get(wcmwf_approveCnt).type == "{http://www.alfresco.org/model/content/1.0}person")
               {
                  to = bpm_assignees.get(wcmwf_approveCnt).properties.email;
               }
               else
               {
                  to = search.findNode(bpm_assignees.get(wcmwf_approveCnt)).properties['cm:email'];
               }

               mail.parameters.to = to ;
               mail.parameters.subject = subject ;
               mail.parameters.from =  from ;

               var mailText = "Review the content created by " + initiator.properties.userName + "\n";
               mail.parameters.text =  mailText;
               mail.execute(bpm_package);
            </script>
         </action>
      </transition>
    </decision>

Please let me know if you have any problem in above code.