cancel
Showing results for 
Search instead for 
Did you mean: 

Send mail to Assignee of Adhoc Workflow.

orbitron
Champ in-the-making
Champ in-the-making
Hello all,

I have seen several topics related with my problem, but after read all of them I can not understant why is not working my configuration. Just say that I receive the mails correctly when the workflow is complete and the "Notify me" checkbox is select, so I assume all the mail configuration is correct. But It is impossible for me configure Alfresco to send a message to the Assignee when the task is created.
Any help or hint will be appreciate.
Here I posted my adhoc_proccessdefinition.xml, thanks in advance.
Note: I have tried also with hardcoded mail address instead of "bpm_assignee.properties.email, etc"


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

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

   <swimlane name="initiator"/>

   <swimlane name="assignee">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{bpm_assignee}</actor>
      </assignment>
   </swimlane>

   <start-state name="start">
      <task name="wf:submitAdhocTask" swimlane="initiator"/>
       <transition name="" to="adhoc">
        <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
           <script>
            <!– Send a notification email to the reviewer –>
            var mail = actions.create("mail");
            mail.parameters.to =  bpm_assignee.properties.email;
            mail.parameters.subject = "New Task";
            mail.parameters.from = initiator.properties.email;
            mail.parameters.text = "Test";
            mail.execute(bpm_package);
          </script>
        </action>
     </transition>
   </start-state>

   <task-node name="adhoc">
      <task name="wf:adhocTask" swimlane="assignee">
              <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">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
           <script>
              if (wf_notifyMe)
              {
                 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! Task has been finished.";
                 mail.execute(bpm_package);
              }
           </script>
         </action>
      </transition>
   </task-node>

   <task-node name="completed">
      <task name="wf:completedAdhocTask" swimlane="initiator"/>
      <transition name="" to="end"/>
   </task-node>

   <end-state name="end"/>

</process-definition>
4 REPLIES 4

patil
Champ on-the-rise
Champ on-the-rise
try the below code,
Make sure assignee is having the proper emailID.Make sure task is getting assigned to him.

If it does not work in place of Javascript put the Java code and send the mail.

<event type="task-assign">
               <action class="com.cignex.workflow.SerialWFMailNotificationAction"/>
         </event>



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

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

   <swimlane name="initiator"/>

   <swimlane name="assignee">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{bpm_assignee}</actor>
      </assignment>
   </swimlane>

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

   <task-node name="adhoc">
      <task name="wf:adhocTask" swimlane="assignee">
              <event type="task-create">
                 <script>
                    if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                    if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
                 </script>
              </event>
<event type="task-assign">
   <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
           <script>
            <!– Send a notification email to the reviewer –>
            var mail = actions.create("mail");
            mail.parameters.to =  bpm_assignee.properties.email;
            mail.parameters.subject = "New Task";
            mail.parameters.from = initiator.properties.email;
            mail.parameters.text = "Test";
            mail.execute(bpm_package);
          </script>
       </action>
</event>
      </task>
      <transition name="" to="completed">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
           <script>
              if (wf_notifyMe)
              {
                 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! Task has been finished.";
                 mail.execute(bpm_package);
              }
           </script>
         </action>
      </transition>
   </task-node>

   <task-node name="completed">
      <task name="wf:completedAdhocTask" swimlane="initiator"/>
      <transition name="" to="end"/>
   </task-node>

   <end-state name="end"/>

</process-definition>

orbitron
Champ in-the-making
Champ in-the-making
Hello,

I have tried your code but I have the same effect.  😞 In any case, thank for your support.

Anyway:
What I don't undertand at all is that I have modified the text for the "Notify Me" mail:
mail.parameters.text = "It's done";
to
mail.parameters.text = "It's done! Task has been finished.";

But I am still receiving a short "It's done" like mail when the task is completed. So… either this file is not the correct one or either … (no idea)…

I have look for any file with the text "It's done" in the complete Alfresco installation but it is only inside:
tomcat/webapps/alfresco/WEB-INF/classes/alfresco/workflow/adhoc_processdefinition.xml

Does anybody any idea about what's going on?

patil
Champ on-the-rise
Champ on-the-rise
Hi,

I think you are making the mistake in deployment configuration.
Do one thing replace the

D:\Alfresco3.3\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\workflow\adhoc_processdefinition.xml with your file.

Then
D:\Alfresco3.3\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\bootstrap-context.xml
find the below code
  <props>
                    <prop key="engineId">jbpm</prop>
                    <prop key="location">alfresco/workflow/adhoc_processdefinition.xml</prop>
                    <prop key="mimetype">text/xml</prop>
                    <prop key="redeploy">false</prop>
                </props>

replace with
<props>
                    <prop key="engineId">jbpm</prop>
                    <prop key="location">alfresco/workflow/adhoc_processdefinition.xml</prop>
                    <prop key="mimetype">text/xml</prop>
                    <prop key="redeploy">true</prop>
                </props>

Restart server. By making the redeploy true, your new definition will be registered with the new version.
Once it works you can migrate your changes to the extension environment.

Thanks,
Patil
Cignex Technologies
Bangalore

orbitron
Champ in-the-making
Champ in-the-making
Smiley Tongue Perfect!

You solve me the problem. Thank you very much! I didn't know this topic about hte bootstrap context file.
Thanks!