Mar 152009
 

When dealing with workflows, a commonly requested feature is the ability to have automated E-Mails sent out from the workflow.  Alfresco documents a way to do this via the AlfrescoJavaScript action, by writing some Javascript code to send out the E-Mail.  While this approach provides great flexibility, it also requires your Javascript skills to be up to par.  Wouldn’t it be great to have a specialized E-Mail action instead that could be configured via XML?  Of course it would.

Here’s a simple example of how such an action could be used:

<action class="org.alfresco.repo.workflow.jbpm.Mailer" config-type="bean">
   <to>alfresco@localhost</to>
   <from>info@alfresco.com</from>
   <subject>Content awaiting review!</subject>
   <text>New changes have been submitted and are awaiting your review!</text>
</action>

This is a bit easier to work with as a workflow author than having to code an E-Mail action being sent via Javascript. It does have some limitations though in this simple form, so let’s enhance it a little further. A few things that might be desirable include:

  • Comma and/or semicolon separated E-Mail addresses
  • Variable resolution of E-Mail addresses
  • Variable resolution of task assignee E-Mail addresses (bpm:assignee)
  • Variable resolution of multiple task assignee E-Mail addresses (bpm:assignees)
  • Variable resolution of task group assignee E-Mail addresses (bpm:groupAssignee)
  • Variable resolution of multiple task group assignee E-Mail addresses (bpm:groupAssignees)
  • Variable resolution within the subject and body text

By implementing an Alfresco jBPM action to handle these various requirements, one could ultimately specify a quite dynamic E-Mail action, such as the following:

<action class="org.alfresco.repo.workflow.jbpm.Mailer" config-type="bean">
   <to>bob@example.com, ${bpm_groupAssignees}, ${somewf_somePersonsEmail}, jane@example.com</to>
   <from>info@alfresco.com</from>
   <subject>Content awaiting review!</subject>
   <text>New changes have been submitted and are awaiting your review!</text>
</action>

Further enhancements could include leveraging E-Mail templates already registered with the repository.  To get your hands on an implementation of the E-Mail action described here, see improvement ALFCOM-2555 in Alfresco’s JIRA.  If you have suggestions for how to further improve this simple extension, please comment here!

Reblog this post [with Zemanta]