1

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.

 mail.setTemplateID(templateId.Id); 

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

2

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.

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.