cancel
Showing results for 
Search instead for 
Did you mean: 

Notify assignees by email

joaotpd
Champ on-the-rise
Champ on-the-rise
Hi all!
I'm using alfresco-community-tomcat-2.9.0B on linux…
I create a new workflow that allows to send tasks to many users… Now i want to notify them all with an email… I've tried things like:


mail.parameters.to = bpm_assignees.properties["cm:email"];


mail.parameters.to = bpm_assignees.properties.email;



… but nothing seems to work… alfresco keep saying:
A system error happened during the operation: Failed to signal transition 'null' from workflow task 'jbpm$347'.
In the log file i can read something like:
Cannot read property "cm:email" from undefined (AlfrescoScript#1)
or
Cannot read property "email" from undefined (AlfrescoScript#1)

My workflow is something like this:

<node name="startreview">
        <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
            <foreach>#{bpm_assignees}</foreach>
            <var>reviewer</var>
        </action>
        <event type="node-enter">
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                 <script>
                    var mail = actions.create("mail");
                    mail.parameters.to = bpm_assignees.properties["cm:email"];
                    mail.parameters.subject = "New task on Alfresco!!! " + bpm_workflowDescription;
                    mail.parameters.from = "admin@test.test";
                    mail.parameters.text = "Please Approve or Reject …";
                    mail.execute(bpm_package);
                 </script>
           </action>
        </event>
        <transition name="toApprove" to="toApprove" />
</node>

Can anyone help please!!!
Thanks!!

João Duarte
11 REPLIES 11

vinaxwater
Champ in-the-making
Champ in-the-making
This code for send mail:
var mail = actions.create("mail");
                 mail.parameters.to = initiator.properties.email;
                 mail.parameters.subject = "Adhoc Task " + bpm_workflowDescription;
                 mail.parameters.from = bpm_assignee.properties.email;
                 mail.parameters.text = "It's done";
                 mail.execute(bpm_package);

Please check again parameter in web-client-config-properties.xml at line (it's want this line):

<show-association name="bpm:assignee" display-label-id="wf_reviewer"/>
and this line in file model:

<mandatory-aspects>
     <aspect>bpm:assignee</aspect>
</mandatory-aspects>

joaotpd
Champ on-the-rise
Champ on-the-rise
Hi vinaxwater!
Thanks for your answer!! Smiley Happy That code for send mail is used if you have one assignee only… I have many… :s So i use "bpm:assignees" like described here: http://wiki.alfresco.com/wiki/WorkflowAdministration#The_Start_Task.
My problem is how to send an email to many!! :s
Anyone??! …
Thanks again…

João Duarte

roxanne
Champ in-the-making
Champ in-the-making
HI João Duarte

Is your notification is working in process_defintion.xml ?please tell me the configuration need to do for the same.

Thanks
rox

vinaxwater
Champ in-the-making
Champ in-the-making
Oh! This is code in Node Object in process_defintion.xml for sendmail:


<node name="test">
   <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
            <foreach>#{bpm_assignees}</foreach>
            <var>user</var>
       </action>
      <transition to="task">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                 <script>
                    if (wf_notifyMe)
                    {
                       var mail = actions.create("mail");
                       mail.parameters.to = user.properties.email;
                       mail.parameters.subject = "Test Document Task " + bpm_workflowDescription;
                       mail.parameters.from = initiator.properties.email;
                       mail.parameters.text = "You have a TASK from" + initiator;
                       mail.execute(bpm_package);
                      
                       var mail1 = actions.create("mail");
                       mail1.parameters.to = initiator.properties.email;
                       mail1.parameters.subject = "List email assignee: " + user.properties.userName;
                       mail1.parameters.from = initiator.properties.email;
                       mail1.parameters.text = "You have a TASK from" + initiator;
                       mail1.execute(bpm_package);
                    }
                 </script>
                   </action>
      </transition>
</node>

joaotpd
Champ on-the-rise
Champ on-the-rise
… just what i need!!!  Smiley Very Happy
Thank you very much!!

João Duarte

maha
Champ in-the-making
Champ in-the-making
hi,

I have added that mail code in processdefinition.xml file.Still i am getting " Cannot read property "email" from undefined"

error.Can anyone please help me to resolve this error.

Thanks,

vinaxwater
Champ in-the-making
Champ in-the-making
Hi,
You check field email when You create new user, this field is not Empty  :mrgreen: Good luck!

Regards

scottf
Champ on-the-rise
Champ on-the-rise
Hi,
I'm trying to do the same but cannot find where the "wf_notifyMe" variable in the IF Statement is set
 if (wf_notifyMe)

Anyone know?

Thanks.

Oh! This is code in Node Object in process_defintion.xml for sendmail:


<node name="test">
   <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
            <foreach>#{bpm_assignees}</foreach>
            <var>user</var>
       </action>
      <transition to="task">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                 <script>
                    if (wf_notifyMe)
                    {
                       var mail = actions.create("mail");
                       mail.parameters.to = user.properties.email;
                       mail.parameters.subject = "Test Document Task " + bpm_workflowDescription;
                       mail.parameters.from = initiator.properties.email;
                       mail.parameters.text = "You have a TASK from" + initiator;
                       mail.execute(bpm_package);
                      
                       var mail1 = actions.create("mail");
                       mail1.parameters.to = initiator.properties.email;
                       mail1.parameters.subject = "List email assignee: " + user.properties.userName;
                       mail1.parameters.from = initiator.properties.email;
                       mail1.parameters.text = "You have a TASK from" + initiator;
                       mail1.execute(bpm_package);
                    }
                 </script>
                   </action>
      </transition>
</node>

jayjayecl
Confirmed Champ
Confirmed Champ
"wf_notifyMe" is implicitly referring to this great article about advanced workflows :
http://ecmarchitect.com/archives/2007/11/19/785