I would like to customize the email template for workflow event notification to include the payload title. Is title exposed in some way to use in workflow emails? From the documentation I can see that the options available are ${payload.data}, ${payload.type}, ${payload.path} -- where can I pull back payload title?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @majohns0321
You can retrieve the page title in the Workflow model and set it based on the custom template. Please see the code below:
Map<String, String> valuesMap = new HashMap<>();
valuesMap.put("Time", Calendar.getInstance().getTime().toString());
valuesMap.put("Step", workItem.getNode().getTitle());
valuesMap.put("Workflow", workItem.getWorkflow().getWorkflowModel().getTitle());
valuesMap.put("Content", workItem.getWorkflowData().getPayload().toString()); // Here I am reading the content and printing on the email, same way you can read any property from payload and send it to template.
StrSubstitutor strSubstitutor = new StrSubstitutor(valuesMap);
HtmlEmail email = createEmail(template, strSubstitutor);
email.setTo(emailRecipients);
this.messageGatewayService.getGateway(HtmlEmail.class).send(email);
Now in template read like below:
<div style="font-family:Calibri;font-size:11.0pt">
-------------------------------------------------------------------------------------
Time: ${Time}
Step: ${Step}
Workflow: ${Workflow}
-------------------------------------------------------------------------------------
Content: ${Content}
-------------------------------------------------------------------------------------<br/>
This is an automatically generated message. Please do not reply.
</div>
Thanks!
Hi @majohns0321
You can retrieve the page title in the Workflow model and set it based on the custom template. Please see the code below:
Map<String, String> valuesMap = new HashMap<>();
valuesMap.put("Time", Calendar.getInstance().getTime().toString());
valuesMap.put("Step", workItem.getNode().getTitle());
valuesMap.put("Workflow", workItem.getWorkflow().getWorkflowModel().getTitle());
valuesMap.put("Content", workItem.getWorkflowData().getPayload().toString()); // Here I am reading the content and printing on the email, same way you can read any property from payload and send it to template.
StrSubstitutor strSubstitutor = new StrSubstitutor(valuesMap);
HtmlEmail email = createEmail(template, strSubstitutor);
email.setTo(emailRecipients);
this.messageGatewayService.getGateway(HtmlEmail.class).send(email);
Now in template read like below:
<div style="font-family:Calibri;font-size:11.0pt">
-------------------------------------------------------------------------------------
Time: ${Time}
Step: ${Step}
Workflow: ${Workflow}
-------------------------------------------------------------------------------------
Content: ${Content}
-------------------------------------------------------------------------------------<br/>
This is an automatically generated message. Please do not reply.
</div>
Thanks!
Views
Likes
Replies
Views
Likes
Replies