I've been working with Process Builder and using Email Alerts to send email.

There is a requirement to have the due date calculated as a certain number of Business Days in the future. I wrote an InvocableProcess that creates a Task and sends an email. I'm working on the email portion now. The email template has dynamic fields like {!Opportunity.Name} and {!Task.Subject}. I know these fields get filled in when sent as an Email Alert. When I reference a template in the email what happens.


Does it perform the substitution? How does the email know which Opportunity and Task to reference? Can someone describe the operation? Thanks.

1 Answer 1


You call setWhatId and setTargetObjectId to specify the related records. Once you do that, the email template knows how to merge the values from the record in to the template's text. It's rendered at the moment you call sendEmail or renderEmailTemplate.

You must log in to answer this question.

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