AnsweredAssumed Answered

adhoc_processdefinition.xml to send email on task creation.

Question asked by madtechsupport on Nov 24, 2010
Latest reply on May 20, 2011 by marianamlopes
Dear All,

I need some help modifying adhoc_processdefinition.xml so that it will send an email to the person who the task has been assigned to at task creation time.

I understand that I will need to insert the below code block into the relevant section of adhoc_processdefinition.xml, but doing that successfully has so far evaded me.  Please help!

<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
       <script>
             var mail = actions.create("mail");
             mail.parameters.to = bpm_assignee.properties.email;
             mail.parameters.subject = "New Adhoc Task " + bpm_workflowDescription;
             mail.parameters.from = initiator.properties.email;
             mail.parameters.text = "You have been assigned a new task.";
             mail.execute(bpm_package);
       </script>
</action>

Below is my adhoc_processdefinition.xml in its original form from my Alfresco Community Edition 3.4.b (Windows) installation.  If someone could point me to where in this file I need to insert the code block I would be most thankful.

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

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

   <swimlane name="initiator"/>

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

   <swimlane name="assignee">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{bpm_assignee}</actor>
      </assignment>
   </swimlane>
  
   <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";
                 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>

Regards,


Warren.

Outcomes