Sample Automation Scripts

Custom email template

# use the I18N class to display localized labels, the recipient's locale will be used
$I18N.get('dear') $assignee.fullName, $I18N.get('youareassignedtotask') <b>$taskName</b> $I18N.get('ofworkflow') <b>$workflow</b>
<hr/>

# display the links to take one of the possible actions defined for the current task
<b>$I18N.get('actions')</b>:
#foreach( $action in $actions)
  | <a target="_blank" href="/$WorkflowTool.completeUrl($task, $action, $assignee)">$action</a>
#end
<hr/>

# display the clickable list of the documents appended to the current workflow
<b>$I18N.get('documents')</b>:
#foreach( $doc in $documents )
  <br/>$doc.fileName | <a target="_blank" href="/$DocTool.downloadUrl($doc)">$I18N.get('download')</a> | <a target="_blank" href="/$DocTool.displayUrl($doc)">$I18N.get('display')</a>
#end

# iterate over the events of the current workflow to find the most recent one and save it in the lastAction variable
#set($hists = $WorkflowTool.getHistories($processId, null))
#foreach( $hhit in $hists )
   #if($hhit.taskName)
     #if($hhit.taskName != $taskName)
        #set($lastAction = $hhit)
        #break
     #end 
   #end   
#end

# display the last action taken inside the workflow
#if($lastAction) 
  <br/><br/>last taken action: $lastAction.taskName 
#end

# retrieves all the workflow annotations left until now
#set($hists = $WorkflowTool.getHistories($processId, 'task.note'))

# prepare a table to display the workflow annotations
<br/><br/>Annotations<br/>
<table>
<tr><td>Date</td><td>User</td><td>Annotation</td></tr>

#foreach( $hhit in $hists )
   <tr>
      <td>$hhit.date</td>
      <td>$hhit.username</td>
      <td>$hhit.comment</td>
   </tr>
#end
</table>

A customization of the email template used to notify users about workflow tasks. This proposal differs from the standard template because it includes the list of annotations left on the workflow by the other users. In this script you can see the usage of the I18N class to print localized labels. The current workflow instance is referenced by the variable processId.