2

A while back I accidentally discovered this GREAT feature of Salesforce where I could display a merged email template via a URL.

It was a great feature to show sample emails in my help documentation.

I documented it in my wiki at the time.

The syntax is https://instance.content.force.com/email/templaterenderer?id=XXX&recipient_type_id=XXX&base_href=https%3A%2F%2Finstance.salesforce.com&related_to_id=XXX&preview_frame=previewFrame&render_type=REPLACED_HTML_BODY&setupid=CommunicationTemplatesEmail

Now it is not working. I know you should not rely on these "hacks" from Salesforce but it was a really good one.

I have searched the Salesforce documentation for templaterenderer with no luck.

Does anyone know either how I can get templaterenderer working again now, or how I can display a merged email template easily?

Thanks

2

Jodie -- you got me curious and while I'm not sure exactly how you intend on using this.... but the following URL works fine in my Dev Edition

https://myDomainPart1--c.myPod.content.force.com/email/templaterenderer?
id=theEmailTemplateId
&related_to_id=thetargetObjectId
&base_href=https%3A%2F%2FmyDomain
&preview_frame=contentFrame
&render_type=REPLACED_HTML_BODY

where:

myDomainPart1 is the portion of My Domain before the `my.salesforce.com`
theEmailTemplateId is the ID of the email template to be rendered
theTargetObjectId = the ID of the object that provides the merge fields
myDomain is the full My Domain value

so, if MyDomain is foo-dev-ed.my.salesforce.com, we get:

https://foo--c.na2.content.force.com/email/templaterenderer?
id=00X40000001rPmI
&related_to_id=a094000000P3BVf
&base_href=https%3A%2F%2Ffoo-dev-ed.my.salesforce.com
&preview_frame=contentFrame
&render_type=REPLACED_HTML_BODY

If you go to this URL, the following page appears (sample email template with delightful 1994 styling):

enter image description here

If you want to see what the URL would look like for your org, use your Browser Tools and examine the Network tab for the GET request on templateRenderer and see the full URL used in the Headers as shown in the screen shot below (click image to see full size)

enter image description here

|improve this answer|||||
  • 1
    Wow, thanks Eric, that is fabulous work. I just found that my URL was now working, so came back to update this question, so I don't know if they fixed something on Salesforce end. The way I found the URL is to go to View Frame Source from the preview when you click the Send Test and Verify Merge Fields button. So it is great to know you can actually use this solution with a few less parameters. – JodieM Mar 8 '16 at 2:47
  • 1
    I would add that you may need recipient_type_id= sometimes, depending on if you have fields relating to the recipient. – JodieM Mar 8 '16 at 2:50
  • 1
    So, how I use it is in the internal knowledge documents. I have a complex series of Visualforce emails that go out to clients at different stages along their sales journey. I have a set of sample records that replicate this journey and a knowledge article that does a live preview of the email template that is sent out at that stage, and the sample records show how the fields are set to make everything correct for that stage. – JodieM Mar 8 '16 at 2:53
  • 1
    I also use this in a formula to create a hyperlink on the record showing "latest email sent" - so the users can click on the hyperlink and see a live preview of what text "should have been" sent in the last email. (Not an "Audit" solution at all, but until I can get some coding done to save the email text into Chatter then it has to do for now). – JodieM Mar 8 '16 at 2:55

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.