function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sarika PatelSarika Patel 

How to add a custom string based on condition in the email template?

Hi,

I have a requirement to automate Purchase Order Emails, meaning if an Opportunity is Closed Won, Sales Manager can click on 'Send PO Email' button, and then email template will be previewed by him.

In this case, I was able to generate successfully the template and all, I have one issue, the template comprises instruction for different departments like Support, Training etc. Now if the purchase order is just for training then the field for 'Instructions for Support' should not be populated. As in my template, I have caption:
Support: {!Closing Instructions for Suppport} 
Training: {!Closing Instructions for Training},

So in the above mentioned scenario the email template should have only 
Training: {!Closing Instructions for Training} and not Support: {!Closing Instructions for Suppport}  based on my condition field that the product is for training.

Could anyone please advice?

Thanks
Sarika Patel

kevin lamkevin lam
You can use formulas in email templates, e.g.

{!IF(Purchase_Order__c.Department__c = "Support", Purchase_Order__c.Support_Instructions__c, Purchase_Order__c.Training_Instructions__c)}