How to Use Lightning Email Templates in Salesforce Flow

In Salesforce, whenever there are repetitive tasks, we can send emails using Lightning Email Templates with Salesforce Flows to increase productivity.

In this Salesforce tutorial, we will learn how to use lightning email templates in Salesforce Flow with real scenarios and explanations.

What is a lightning email template in Salesforce?

In Salesforce, Lightning Email Templates are the most recent versions of email templates. You can use the lightning email template with your users, which are predefined email structures with the Email body and Subject that are currently used with Workflows, Process Builders, and Salesforce Flows.

Let’s consider a scenario in which whenever a user updates a case priority to high, we need to send a confirmation mail to the customer that we have taken their case as a high priority. Now, we will automate this email-sending process with the help of Salesforce Flow.

Prerequisite: We need a lightning email template. I have created an email template already.

We can use fields dynamically in the template, which means whenever we create a template, we include the object fields, so when the email is sent, the value will apply to those fields accordingly.

Lightning Email Templates in Salesforce

You can read the whole article on How to Create a Lightning Email Template in Salesforce Lightning.

How to Use Lightning Email Templates in Salesforce Flow

Using the above scenario and the following steps, we can use classic email templates in Salesforce Flow.

Create Record-Trigger Flow:

1. Log in to Salesforce Org. -> Click on the Setup -> Home Tab -> In Quick Find Box, Search for Flows. You will see an option under Process Automation -> Click on Flows.

See also  How to Add Record Type in Salesforce Flow

Then, click on the New Flow button to create a new flow.

2. Here, when the case record is updated, an email should be sent to the customer. For that, create a flow with Record Trigger Flow. 

Now, we will create the following elements in the flow according to the flow diagram displayed in the following Flow Diagram.

How to use a Lightning Email Template in Salesforce Flow

1. Record-Trigger Flow:

3. In our scenario, the flow should trigger when we update a Case record. That’s why I have selected the Case in the Object field. In Configure Trigger, I have selected A Record is Updated because when we update the record, the flow should trigger.

Use Lightning Email Template in Salesforce Flows

4. Then, we have to Set Entry Conditions, and in the Condition Requirement option, we have to select All Conditions Are Met(AND) because the following conditions should meet the criteria.

Here, the flow has to trigger only when the Case Priority = High and ContactID is Not Null.

5. Then we need to select Every time a record is updated and meets the condition requirements: When you select this option, the flow will trigger every time you update the record when the condition matches the entry condition.

We are going to send an email notification to the customer using the Classic Email Template, so we have to select Optimize the Flow for Action and Related Records.

Use Lightning Email Template using Flows in Salesforce

2. DeveloperName of Lightning Email Template:

6. We need a DeveloperName of email template for that go to the Lightning Email Template that you have created. Then, go to the detail page of the template, and then on the URL, you can see ID copy that ID. Then Setup. -> Developer Console.

Lightning Email Template in Salesforce

7. Then click on the Query Editor on the Developer Console. Enter the query: Select id, Name, DeveloperName from EmailTemplate Where id=’Paste copied ID’ -> click on Execute Query, and you will get the Developer Name. Copy the developer’s name.

Lightning Email Template in Salesforce Flow

3. Get Records(Get Email Values):

8. Then, we need to fetch the Classic Email Template. For that, we need to select the Get Records element and enter a Label and API Name into it.

See also  How to Create Variables Using Flow Builder in Salesforce

9. In the Object field, select the Email Template object. To fetch the template, paste the copied developer name in the DeveloperName = Email_to_Customer_1712643015767 (the API Name of the Lightning email template). After this, leave the other fields as they are and click on the Done button.

How to use Lightning Email Template in Salesforce Flows

4. Action Element(Send an Email):

10. Then add an Action Element. To add an action element, click on the + plus icon, and then you will see the Action Element. Then click on the All category.

As you click on it, you need to add Action in the Action field. To send an email, we have to select the Send Email action. Then, enter the Label, and the API Name will automatically populate. The description is optional; you can give a short intro about this Action element.

Send Email Action in Salesforce Flow

11. Now, we need to Set Input values for the Selected Action. Here, we have to assign values to the Email object fields.

  • Sender Email Address: In this field, we need to provide who is sending an email; we can add the user’s and owner’s email. I have selected the user’s email.
  • Email Template ID: In this field, we need to provide a template ID from the Get Record element, where we stored the lightning email template with the Get Email Values label.
  • Log Email on Send: Email logs contain email data on each message that has been sent, including the sender’s details. Here, I have set it as True.
  • Recipient ID: Here, we need to add to whom we want to send an email so we will get the recipient ID on the contact object.
How to use Lightning Email Template in Salesforce Flow example

5. Save:

12. After setting up all labels and conditions, click the Save button to save the flow. For that, we need to enter the Flow Label; the API Name will automatically populate as we click the text box. The Description is optional; we can introduce our flow Shortly.

See also  Automatically Assign PricebookId to Opportunities using Salesforce Flow

6. Debug & Activate:

13. After Saving the flow, click on the Debug button. Then click on the Activate button; always remember to debug the flow before activating it. It’s good practice to use flow.

How to use a Lightning Email Template in Salesforce Flow

14. After Activating the flow, let’s check how it is working; for that, go to the Case object and select any Case Record to update. Here, I have updated the case with the Contact Name Andy Young and updated the Priority from Low to High.

15. Here, you can see I got an email with the Subject, Body, Name, and Case ID that we declared in the Lightning Email Template.

Use Lightning Email Template in Salesforce Flow example

This is how we can use lightning email templates in Salesforce Flow.

Conclusion

I hope now you have an idea about lightning email templates. In that, we have seen what an email template in Salesforce is and how to use lightning email templates in Salesforce Flow by action element with real-time scenarios and step-by-step explanations.

You may like to read: