error when sending the e-mail template if a variable is used in a "headline"-element
sandro-pagliara28 opened this issue · 4 comments
sandro-pagliara28 commented
Bug report
Describe the bug
When sending the email programmatically, we pass a variable (e.g. service.title) . We use this in the e-mail template in a headline element. When triggering the email, we get the error (SERVICE is not defined).
Steps to reproduce the behavior
- Add any Variable programmatically.
- Open the E-Mail-Template, add a headline-Element and write the variable in it.
- See error when triggering the email.
Expected behavior
You should be able to use a variable in a headline element.
System
- Node.js version: > v14.21.2
- YARN version: v1.22.19
- Strapi version: v4.5.6
- Plugin version: 2.1.2
github-actions commented
Thank you!! This is your first issue on this repo
mypostofice24 commented
I confirm there is a problem
5ika commented
Same problem. The variable name is uppercased (service
=> SERVICE
) so it's not recognized during the variable replacement.
5Gears0Chill commented
found a workaround
in your template write it as follows
{{= FIRSTNAME}}
then in your controller:
await strapi
.plugin('email-designer')
.service('email')
.sendTemplatedEmail(
{
// required
to: options.to,
},
{
// required - Ref ID defined in the template designer (won't change on import)
templateReferenceId: options.templateReferenceId,
},
options.parameters,
);
where options looks like this:
{
"to": "johndoe@gmail.com",
"templateReferenceId": 1,
"parameters":{
"FIRSTNAME": "John Doe"
}
}