We are having several VF templates that are used in an email alert in a Process.

When we trigger the Process from Apex, then the Process is run, but the email template is not merged properly (even though it is sent to the proper email address): the recipient and the relatedTo are not resolved, so all merge tags show empty. Using workflows instead of a Process yields the same negative result.

My observations:

  • The templates merge fine when we test them manually (i.e. without triggering the Process, but do a test-and-verify)
  • The templates merge fine when we trigger the Process through the UI (i.e. we edit a record via the UI, the Process runs)
  • The templates DO NOT merge when we trigger the Process/Workflow from Apex code (i.e. we edit the record via Apex)

​Can anybody confirm this and/or share a solution? Thanks!

For reference, this is the simplest email template I could produce:

<messaging:emailTemplate subject="TEST" recipientType="Contact" relatedToType="Check__c">
    <messaging:htmlEmailBody >
        Hey {!relatedTo.Guest__r.FirstName}

Then we have an email alert that is based on this email template, and that sends the email to Related Contact: Guest.

Then either a Workflow or a Process sends an email alert, from a Check__c record that has Check__r.Guest__c definitely filled in. The email is sent to the proper email address.

Yet, what is generated is "Hey " and not "Hey Frank" (or any other name).

  • So, what you're saying is this is an issue you're having with Process builder? If it's not picking up the WhoID, how is it managing to get the proper email address, or does that only happen when the WhoID is not the recipient? If that's the case, I think you may need to post more details about the triggering object and the related objects.
    – crmprogdev
    May 20, 2016 at 15:23
  • @crmprogdev Yes, it's only happening via the Process Builder. It does find the proper email address, but it does not provide the proper merge tags to the Email Template. Thus, the email template renders broken, but the mail is sent to the proper WhoID. Any clue? Could you try to reproduce? May 20, 2016 at 15:25
  • Again, we need to know more in order to reproduce. What object, what fields, what conditions, etc. Can you post your template code and conditions for it being fired by PB?
    – crmprogdev
    May 20, 2016 at 16:02
  • @crmprogdev you're right. Sorry for that. I updated the question with a simple example. May 20, 2016 at 16:41
  • 1
    No, afraid not. See Order of Execution. Load Record, Validation Rules, Before Triggers, Save without Commit, After Triggers, Assignment Rules, Workflow, Rerun Triggers, PB, Esc Rules, Roll-ups, etc, finally Commits to Database, last thing is to send post commit actions like emails.
    – crmprogdev
    May 20, 2016 at 17:01

1 Answer 1


I found it! The issue was that we were running the Apex from a Force.com Site, and the profile missed the Field Level Security for the Guest__r lookup field.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .