Salesforce Flow Is an automation tool provided by Salesforce which can be used to perform various tasks like, Sending an Email, Posting a chatter, Sending custom Notifications &, etc. Flow is the most powerful automation tool provided by Salesforce. It can be trigger for record insert, update and record delete and it can be run for both after and before events.
Scenario - Sending a Welcome email to the new Student of Numpy Ninja whenever a Student record is created in the student object with the given email ID.
To complete the task we have to work on two steps which are
Step 1 - Create an Email Template and Email alert in the lightning.
Step 2 - Create a Record-Triggered Flow.
Email Templates in Salesforce
Currently in Salesforce we have and both of these are used in different situations.
Classic Email Templates - Salesforce Classic Email Templates are currently used with Workflow or Process Builder to automate email alerts. The emails are sent automatically once triggered by a certain event, such as when a transaction is approved.
Salesforce Lightning Email Templates - Salesforce Lightning Email Templates are currently used for communicating with your customers one-on-one. This email system is not automatic, meaning you can’t automate it. But you can create email templates to use when you are communicating with any of your customers
What is Record-Triggered Flow ?
Record Triggered Flow launches when a record is created, updated, or deleted. Earlier Apex triggers were used to do some of the automations but now it can be done with the Flows.
Step 1 - Creating an Email Template and Email alert in the Lightning.
1) Go to App Launcher.Click on New Email Template.And make sure that Student object is selected as we have to send email from the field which is available in the Student object.
2)Draft the email by using different styles, adding images and also here we can add the URL link to the template and save it.
3)Once the email template is ready, now we have to create an email alert so that we can use this email alert in the flow.
4)For that Go to Set up, Search Email alert in the Quick Search , click on New Email alert.
Provide the details
Description - Name the Email alert
Unique Name- Is auto generated
Email Template- The Email template which was created in previous step
Recipient type- Select the Email Field :Email
Save the email alert
Step 2 - Create a Record-Triggered Flow
1). Go to Setup select New flow --Create a Record Trigger flow with free form.
2) Provide the details
Select Object - Student
Configure Trigger - A record is created
And in the Set Entry Conditions
Set Entry Conditions
Field - Email__c
Operator - Is Null
Value - {!$GlobalConstant.False} (False Value)
3)Drag and drop the action element.
4)In the Filter by Select Type as Email Alert.
5)Select the Email alert which we have created and update the API name
6)In the Set Input Values for the record id as {!$Record.Id} This is the id of the record which would be created.Click on Done and save the flow
7)Activate the flow.
Testing
Lets create a new student Record in the LMS application. Go to LMS app and select student object and click on new to create a new student record.
Once the student record is saved an auto email is send to the email id mentioned in the student record.Below is the screenshot of the mail received when the record is saved.