Search code examples
alfrescoalfresco-share

Alfresco - add recipient's name to workflow notification email template


I'm using Alfresco 5.2 Community. I'm trying to edit the template wf-email.html.ftl file found in Repository> Data Dictionary> Email Templates> Workflow Notification> wf-email.html.ftl.

In the line

<p>Hi,</p>

I want to add the recipient's name in the message, something like

<p>Hi John,</p>

Is this possible? If yes, how is it achieved?


Solution

  • Unfortunately, the assignee is not passed as an argument to the template, so it is not available to the template. You can see this by looking at the source of the class that actually sends the notification:

    https://github.com/Alfresco/alfresco-repository/blob/master/src/main/java/org/alfresco/repo/workflow/WorkflowNotificationUtils.java

    Looking at that class you can see where things like the workflow ID, title, and description are added as arguments that get passed to the template renderer:

        templateArgs.put(ARG_WF_ID, taskId);
        templateArgs.put(ARG_WF_TITLE, taskTitle);
        templateArgs.put(ARG_WF_DESCRIPTION, description);
    

    But the assignee is not passed.

    You could lookup the workflow and then get the current task and then get the assignee to that task, but that's probably not the best way to go about it.

    If you really need this, I would extend the existing WorkflowNotificationUtils.java with my own, and add in the assignee as an argument to the template. Or I'd turn off the default notifications and just use my own notification classes that my custom workflows call.