In this blog, we are going to learn about send email action in Salesforce Flow.
Salesforce Flow is currently the sole automation tool for automatically sending customized emails to the target audience as to the retirement of Process Builders and workflows lined up in the near future.
Business Scenario
Send an email ‘Your project limit has been exhausted’ to opportunity records if the project limit exceeds three.
Prerequisite:
- Firstly, create a Project limit custom field of number datatype on the opportunity object.
- Additionally, we create a custom object called ‘Project’ to store project details, which includes fields for Project Name (Auto number), Start Date, and End Date.
- The Opportunity object maintains a Master-Detail relationship with the Project object. The Project object behaves as a child and Opportunity as the parent.
What is the Master-Detail Relationship in Salesforce?
A master-detail relationship in Salesforce is a way to link two objects where one Master(Parent) object controls the behaviour and ownership of the Detail(child) object.
It enforces data integrity, allows cascading updates, and deletes from master to detail records.
To learn more about Master detail relationship in Salesforce, click here
Object selection for Trigger: The factor responsible for the execution of our trigger plays an important while selecting an object.
We send an email when the third project is created for the same opportunity or when the project limit exceeds 3. So, the object for the flow is the Project.
Creating a Flow
We have completed the prerequisite for sending an Email using Flow. Now, let’s proceed with Flow Builder and create a Record-triggered flow.
Choose the condition “Record creation or update” because this flow should execute for both new and updated records.
To run the trigger only for the opportunity records that are present on the project object, set the entry condition as “Opportunity does not equal to false.”
Select ‘Action and Related records’ to perform actions like sending an Email.
Now let’s add, the Get Record element to retrieve the records of the project object that are related to opportunity using {!$Record.Opportunity__c}.
Decision Element: The Decision element checks if the Get Record element has fetched any null records.
Assignment Element: Variable ‘count’ is created to store the size of the get record element. Then using the equals count operator size of the get record element is fetched.
We determined the project limit to be greater than or equal to 3 by checking it using a ‘Check for project limit’ decision element.
We have now divided our flow into two parts: “limit exceeded” and “limit not exceeded” Add send Email action in the limit exceeded loop.
Send Email Action in Salesforce Flow
Several options are provided to enable Flexible email communication processes tailored to your organization’s needs while ensuring consistency and efficiency in your messaging.
Want to Learn Salesforce Flows? Checkout our Salesforce Flow Course
Here is an explanation of various options we have used in the “Send Email” action in our example:
- Body: Compose the email content in the body section. You can use merge fields to dynamically populate information from your Salesforce records. Use the resource “Text Template” and enter:
- Log Email on Send: Set Log email on Send TRUE with {!$GlobalConstant.True}
- Related Record ID: As we want to log an Email on the opportunity object we use Related Record ID using {!$Record.Opportunity__c}
- Recipient Address List: The Recipient Address List includes the use of {!$Record.Opportunity__r.Owner.Email} to send an Email to the opportunity owner.
- Rich-Text-Formatted Body: Set TRUE using {!$GlobalConstant.True} as the body is an HTML Template.
- Subject: It represents the subject of the email, which is “Limit Exhausted Please Check.”
Finally, save the flow and then click on Debug.
Let’s review how the sent Email appears to the Opportunity record owner.
Here are some business use cases for sending emails using Salesforce Flows:
- Use Flows to automatically send welcoming emails to new customers with setup instructions and helpful links.
- As a customer support representative, send automatic email updates to keep customers in the loop about their support issues until the problem is solved.
- As a marketing campaign manager, you can use Flows to automatically send follow-up emails to interested leads or customers, providing them with more information or special offers.
These use cases highlight the versatility of Salesforce Flows in enhancing various aspects of business communication and operations. They enable organizations to streamline processes and ensure better engagement with leads, customers, and clients.
For more details check out the video: