0

I'm trying to work around a requirement with the Send Better Email Flow Action to have a recipient contact record, when using email templates.

My use case, is that I'm sending 'case opened' emails to people submitting access via web-to-case. I want to do this with lightning email templates. There is no problem when WTC matches a single contact, but when multiple, or no contacts are found, the contact details are saved in the web fields, i.e. Web Email, and no contact record is referenced on the case, limiting me to using flow text templates in the SBE flow action.

To reduce maintenance complexity, I want to avoid having to use both lightning email templates, and text templates to store the email body. I'd prefer to use lightning email templates in all cases. I have my lightning email templates set up already, and they are HML templates.

My thinking is that I could reference the HtmlValue of the email template as the flow text template body, however the merge fields won't work now, since the text templates use SML.

I created the formula below to convert the HML to SML-like syntax, by substituting the {{{ and }}} characters in the email template HtmlValue with {! and } respectively.

SUBSTITUTE(
    SUBSTITUTE({!Get_Email_Template.HtmlValue}
    , "{{{", "{!")
, "}}}", "}")

I set the API name of my Get Records elements to the same as the object name, so converting that wouldn't be required.

To recap with an example, the email template HtmlValue references the HML merge field {{{Case.CaseNumber}}}. I want to convert this to {!Case.CaseNumber}. The actual output of my formula is Case.CaseNumber}}.

Why isn't this working? Am I asking too much of the text template and formula functions in Salesforce for this kind of merge field conversion?

0

It seemed like adding the {! first was confusing the markup handling of the text template, leading to the unexpected output. Simply swapping the order of the formula substitutions ended up working for me.

SUBSTITUTE(
    SUBSTITUTE({!Get_Email_Template.HtmlValue}
    , "}}}", "}")
, "{{{", "{!")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.