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

durrell
Champ in-the-making
Champ in-the-making
Does that file need to be edited if alfresco-global.properties is setup for e-mail?

lucille_arkenst
Champ in-the-making
Champ in-the-making
That's where the wiki says to put it http://wiki.alfresco.com/wiki/E-mail_Configuration.  But it also says you could put it in <TOMCAT_HOME>/classes/alfresco-global.properties.  I put mine in repository.properties and it worked.  Try it.  See if it works for you.

thomasberment
Champ in-the-making
Champ in-the-making
Hi, I work on the same workflow and I want send an Email too.

I think you are a problem with the actor "reviewer".

In my view, you must send Email after this code :
<swimlane name="reviewer">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{bpm_assignee}</actor>
      </assignment>   
   </swimlane>

This is my workflow, but it doesn't work, it's probably a problem with my script …
<?xml version="1.0" encoding="UTF-8"?>

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

    <swimlane name="initiator" />

    <start-state name="start">
        <task name="wf:submitReviewTask" swimlane="initiator"/>
         <transition name="inReview" to="node1">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                  <variable name="bpm_package" access="read" />
                  <expression>
                     bpm_package.children[0].properties["custom:statutdocument"] = "En relecture";
                     bpm_package.children[0].save();
                  </expression>
               </script>
            </action>
         </transition>
    </start-state>

   <swimlane name="reviewer">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{bpm_assignee}</actor>
      </assignment>   
   </swimlane>
   
   <node name="node1">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
            <variable name="bpm_package" access="read" />
            <variable name="bpm_assignee" access="read" />
               <expression>
                  <!– Send a notification email to the reviewer–>
                var mail = actions.create("mail");
                mail.parameters.from = "thomasberment@gmail.com";
                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]);
                  </expression>
         </script>
      </action>
      <transition to="review"></transition>
   </node>    
   
    <task-node name="review">
        <task name="wf:reviewTask" swimlane="reviewer">
            <event type="task-create">
              <script>
                 <variable name="bpm_package" access="read" />
                 <variable name="bpm_assignee" access="read" />
                 <expression>
                 if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                  if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
                   </expression>
            </script>
            </event>
        </task>
      <transition name="reject" to="rejected">
      </transition>
       
        <transition name="approve" to="approved">
        </transition>
    </task-node>
   
    <task-node name="rejected">
        <task name="wf:rejectedTask" swimlane="initiator" />
        <transition name="" to="end">
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="bpm_package" access="read" />
                   <expression>
                      bpm_package.children[0].properties["custom:statutdocument"] = "Travail";
                         bpm_package.children[0].save();
                     </expression>
            </script>
         </action>
        </transition>
    </task-node>
   
    <task-node name="approved">
        <task name="wf:approvedTask" swimlane="initiator" />
        <transition name="" to="end">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="bpm_package" access="read" />
                   <expression>
                      bpm_package.children[0].properties["custom:statutdocument"] = "Relu";
                         bpm_package.children[0].save();
                     </expression>
            </script>
         </action>
        </transition>
    </task-node>

    <end-state name="end" />

</process-definition>


EDIT : now it works, I added a node to send my Email. But now I have a problem with "connection timeout" …

I edited files, like write in the wiki

C:\Alfresco\tomcat\shared\classes\alfresco-global.properties :
###############################
## Common Alfresco Properties #
###############################

#
# Sample custom content and index data location
#————-
dir.root=C:/Alfresco/alf_data

#
# Sample database connection properties
#————-
db.name=alfresco
db.username=alfresco
db.password=alfresco
db.host=localhost
db.port=3306

#
# External locations
#————-
ooo.exe=C:/Alfresco/OpenOffice.org/program/soffice
ooo.user=C:/Alfresco/alf_data/oouser
img.root=C:/Alfresco/ImageMagick
swf.exe=C:/Alfresco/bin/pdf2swf

#
# Initial admin password
#————-
alfresco_user_store.adminpassword=209c6174da490caeb422f3fa5a7ae634

#
# MySQL connection
#————-
db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://${db.host}:${db.port}/${db.name}
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect

#
# Index Recovery Mode
#————-
#index.recovery.mode=Auto

#
# Outbound Email Configuration
#————-
# Sample Gmail settings
mail.host=smtp.gmail.com
mail.port=465
mail.protocol=smtps
mail.username=thomasberment@gmail.com
mail.password=************
mail.encoding=UTF-8
mail.smtp.socketFactory.port = 465
mail.smtp.socketFactory.class = javax.net.ssl.SSLSocketFactory
mail.smtp.socketFactory.fallback = false
mail.smtp.timeout = 25000

# New Properties
mail.smtps.starttls.enable=true
mail.smtps.auth=true

#
# Alfresco Email Service and Email Server
#————-

# Enable/Disable the inbound email service.  The service could be used by processes other than
# the Email Server (e.g. direct RMI access) so this flag is independent of the Email Service.
#————-
#email.inbound.enabled=true

# Email Server properties
#————-
#email.server.enabled=true
#email.server.port=25
#email.server.domain=alfresco.com
#email.inbound.unknownUser=anonymous

# A comma separated list of email REGEX patterns of allowed senders.
# If there are any values in the list then all sender email addresses
# must match.  For example:
#   .*\@alfresco\.com, .*\@alfresco\.org
# Allow anyone:
#————-
#email.server.allowed.senders=.*

#
# The default authentication chain
# To configure external authentication subsystems see:
# http://wiki.alfresco.com/wiki/Alfresco_Authentication_Subsystems
#————-
#authentication.chain=alfrescoNtlm1:alfrescoNtlm

#
# IMAP
#————-
#imap.server.enabled=true
#imap.server.port=143
#imap.server.host=localhost

C:\Alfresco\tomcat\shared\classes\alfresco\extension\custom-email-context.xml :
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
<!–                        –>
<!– MAIL SERVICE           –>
<!–                        –>

<bean id="mailService" class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="host">
        <value>${mail.host}</value>
    </property>
    <property name="port">
        <value>${mail.port}</value>
    </property>
    <property name="protocol">
        <value>${mail.protocol}</value>
    </property>
    <property name="username">
        <value>${mail.username}</value>
    </property>
    <property name="password">
        <value>${mail.password}</value>
    </property>
    <property name="defaultEncoding">
        <value>${mail.encoding}</value>
    </property>
    <property name="javaMailProperties">
    <props>
      <prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
      <prop key="mail.smtp.socketFactory.port">${mail.smtp.socketFactory.port}</prop>
      <prop key="mail.smtp.socketFactory.class">${mail.smtp.socketFactory.class}</prop>
      <prop key="mail.smtp.socketFactory.fallback">${mail.smtp.socketFactory.fallback}</prop>
      <prop key="mail.smtp.timeout">${mail.smtp.timeout}</prop>
    </props>
  </property>
</bean>
</beans>

Can you put your config to send e-mail ?

lucille_arkenst
Champ in-the-making
Champ in-the-making
I tried the gmail example (also added parameters, like you did), but it seems like the less code I write, the better it works.  I don't know why.


# Sample Gmail settings
mail.host=smtp.gmail.com
mail.port=465
mail.protocol=smtps
mail.username=user@gmail.com
mail.password=password

# New Properties
mail.smtps.starttls.enable=true
mail.smtps.auth=true

I would temporarily remove any other parameters you have that are not included in the example (like socketFactory, etc.  Remember to comment it from the other files also) and see if it works.

thomasberment
Champ in-the-making
Champ in-the-making
Hi, I tried many solutions to send an Email, but it never works !

I thought of something, I have a proxy. Is it possible that this is my problem ?

durrell
Champ in-the-making
Champ in-the-making
I got this working on my development server (running Alfresco 3.3dev), but I can't get it running on 3.2r. Not sure why. Going to work on it more during my maintenance window on Tuesday.

lucille_arkenst
Champ in-the-making
Champ in-the-making
Hi Durrell, I need to write code to send emails too… so I wanted to use something that we know works already.  I modified review_processdefinition.xml with the code we were discussing before, but it is not working for me.  My email configuration is set up correctly.  Did you have to do anything else to review_processdefinition.xml in order to get it to work?  Also, this process is kicked off when you click "Advanced Workflow" -> "Review & Approve (Review & approval of content)", right?
      <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>

hsohaib
Champ on-the-rise
Champ on-the-rise
Hi, I tried many solutions to send an Email, but it never works !

I thought of something, I have a proxy. Is it possible that this is my problem ?

Sure it could be the problem, some companies requires the host to be in their whitelist in order to send mail, you should check with the administrator

durrell
Champ in-the-making
Champ in-the-making
Hi Durrell, I need to write code to send emails too… so I wanted to use something that we know works already.  I modified review_processdefinition.xml with the code we were discussing before, but it is not working for me.  My email configuration is set up correctly.  Did you have to do anything else to review_processdefinition.xml in order to get it to work?  Also, this process is kicked off when you click "Advanced Workflow" -> "Review & Approve (Review & approval of content)", right?

That's right. I still can't get it working on 3.2r Enterprise. Not sure if my e-mail settings are off or what. 3.3dev Community it works like a champ.

lucille_arkenst
Champ in-the-making
Champ in-the-making
OK… yes, I've heard the Community version is very good.  Thank you for the update.
By the way, are you using your workflow in Alfresco Explorer, or Alfresco Share?  Or both?