Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Workflow email properties

majohns0321
Level 2
Level 2

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?

1 Accepted Solution
Asutosh_Jena_
Correct answer by
Community Advisor
Community Advisor

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!

View solution in original post

0 Replies
Asutosh_Jena_
Correct answer by
Community Advisor
Community Advisor

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!

View solution in original post