cancel
Showing results for 
Search instead for 
Did you mean: 

Send e-mail when person is assigned workflow

durrell
Champ in-the-making
Champ in-the-making
I've researched this and can't find a definitive answer. I'm sure it's fairly straight forward, but I just can't figure out the swimlanes and task events, blah blah blah.

Can anyone point me in the right direction? Basically I need:

Assign document to user for review > send user e-mail notifying them to check dashboard > click document from dashboard > accept or reject > end
47 REPLIES 47

hsohaib
Champ on-the-rise
Champ on-the-rise
you should use the standard example of review workflow, and add the fellowing action to send mail to the personne assigned :


<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <runas>admin</runas>
                 <script>
                    <!– Send a notification email to the reviewer –>
                          var mail = actions.create("mail");
                    mail.parameters.to = bpm_assignee.properties.email;
                    mail.parameters.subject = "new Review Task";
                    mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/notify_user_email.ftl");
                 mail.parameters.text = "A document awaiting your approval at Alfresco";
                    mail.execute(bpm_package.children[0]);
           </script>
</action>

durrell
Champ in-the-making
Champ in-the-making
Thanks for the reply.

Does it matter where this is in the file? It doesn't seem to be working for me.

Is "review_processdefinition.xml" the correct file?

Thanks.

hsohaib
Champ on-the-rise
Champ on-the-rise
sure, it matters where you put it, you want that code to be executed once the initiator submits the document for review, therefor it should be executed when the start task is completed, and the transition to the review task is activated, therefore for "review_processdefinition.xml" the start task becomes :


    <start-state name="start">
        <task name="wf:submitReviewTask" swimlane="initiator" />
        <transition name="" to="review" >
               <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <runas>admin</runas>
                 <script>
                    <!– Send a notification email to the reviewer –>
                          var mail = actions.create("mail");
                    mail.parameters.to = bpm_assignee.properties.email;
                    mail.parameters.subject = "new Review Task";
                    mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/notify_user_email.ftl");
                 mail.parameters.text = "A document awaiting your approval at Alfresco";
                    mail.execute(bpm_package.children[0]);
                 </script>
               </action>
       </transition>
    </start-state>

durrell
Champ in-the-making
Champ in-the-making
That doesn't seem to work for me.

Caused by: org.jbpm.jpdl.JpdlException: [[ERROR] cvc-complex-type.2.4.a: Invalid content was found starting with element 'action'. One of '{"urn:jbpm.org:jpdl-3.1":task, "urn:jbpm.org:jpdl-3.1":transition, "urn:jbpm.org:jpdl-3.1":event, "urn:jbpm.org:jpdl-3.1":exception-handler}' is expected. line 10, [FATAL] The element type "start-state" must be terminated by the matching end-tag "</start-state>". line 22, [ERROR] couldn't parse process definition]

I copied and pasted into the exact spot in the same file, so I'm not sure why it's complaining. Alfresco doesn't start as a result, though.

hsohaib
Champ on-the-rise
Champ on-the-rise
could you past the whole process definition ? it's surely a missing tag somewhere

durrell
Champ in-the-making
Champ in-the-making

<?xml version="1.0" encoding="UTF-8"?>^M
^M
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:review">^M
^M
    <swimlane name="initiator" />^M
^M
    <start-state name="start">^M
        <task name="wf:submitReviewTask" swimlane="initiator" />^M
        <transition name="" to="review" />^M
                <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <runas>admin</runas>
                 <script>
                    <!– Send a notification email to the reviewer –>
                          var mail = actions.create("mail");
                    mail.parameters.to = bpm_assignee.properties.email;
                    mail.parameters.subject = "new Review Task";
                    mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/notify_user_email.ftl");
                 mail.parameters.text = "A document awaiting your approval at Alfresco";
                    mail.execute(bpm_package.children[0]);
           </script>
</action>
</transition>
</start-state>^M
^M
    <swimlane name="reviewer">^M
        <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">^M
            <actor>#{bpm_assignee}</actor>^M
        </assignment>    ^M
    </swimlane>^M
^M

    <task-node name="review">^M
        <task name="wf:reviewTask" swimlane="reviewer">^M
            <event type="task-create">^M
                <script>^M
                    if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;^M
                    if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;^M
                </script>^M
            </event>^M
        </task>^M
        <transition name="approve" to="approved" />^M
        <transition name="reject" to="rejected" />
    </task-node>^M
^M
    <task-node name="rejected">^M
        <task name="wf:rejectedTask" swimlane="initiator" />^M
        <transition name="" to="end" />^M
    </task-node>^M
^M
    <task-node name="approved">^M
        <task name="wf:approvedTask" swimlane="initiator" />^M
        <transition name="" to="end" />^M
    </task-node>^M
^M
    <end-state name="end" />^M
^M
</process-definition>

lucille_arkenst
Champ in-the-making
Champ in-the-making
Hi… hope you don't mind my joining in… the transition tag was closed out too soon:
<transition name="" to="review" />

Once you fix that the start-state tag should look like this:

  <start-state name="start">
    <task name="wf:submitReviewTask" swimlane="initiator" />
    <transition name="" to="review">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
        <runas>admin</runas>
        <script>
          <!– Send a notification email to the reviewer –>
          var mail = actions.create("mail");
          mail.parameters.to = bpm_assignee.properties.email;
          mail.parameters.subject = "new Review Task";
          mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/notify_user_email.ftl");
          mail.parameters.text = "A document awaiting your approval at Alfresco";
          mail.execute(bpm_package.children[0]);</script>
      </action>
    </transition>
  </start-state>

Cheers

durrell
Champ in-the-making
Champ in-the-making
Thanks for the help.

Although the error messages are gone, there are still no e-mails being sent when the workflow process starts. Is there any underlying e-mail setup that is required? I figured it would just use the SMTP server just like the invites do.

lucille_arkenst
Champ in-the-making
Champ in-the-making
The only thing I can think of is to change the "email configuration" section of repostitory.properties.  Have you done that yet?