Salesforce Flows | After Save Update Flow

In this blog I am going to talk about the After Save Flow in Salesforce. These are the latest addition in Flow Trigger capability of Salesforce.

Salesforce Flow Triggers : Create Record Triggered Flow that Run After Save

After Save Update Flows in Salesforce

Salesforce Summer'20 release is here with many exciting features and enhancements and as always we have all the reasons to be excited.
Continuing on my Flow Series, in this blog I am going to showcase one of the most exciting enhancement to the flow capability in this release- Automated Flow Triggers - To perform automatic actions after a record is saved. 

Gone are the days when we had to write triggers or multiple process builders or a combination of flows and process builders for every small automation. Most of the not so complex use cases can be easily achieved now by creating flow triggers.

In the previous release, Salesforce introduced Before Save Trigger option for Flows which is great for validations and updates before saving the record. But now we can do more stuff after record save too which means we have access to the RecordId (of record being inserted or updated) and possibilities are now endless.

Checkout my blog for Before Save Update Flows here: https://accidentalcoder.blogspot.com/2020/06/before-save-update-flows.html

Checkout Latest Post on Is Changed in After Update Flows Salesforce : Is Changed in After Update Flows

Here is the link to Salesforce Release notes for this feature.
https://releasenotes.docs.salesforce.com/en-us/summer20/release-notes/rn_forcecom_flow_fbuilder.htm

Key Takeaways from this article:
  1. Using Flow Triggers for After Save Automations/Actions.
  2. Nested/Child record creation after new record is inserted - Two levels deep
  3. Flows are awesome!
Sample Use Case/Requirement :

Whenever a new Lead record is inserted in Salesforce, we need a new Case to be created. This new case should be associated with the newly created Lead as a child record. Also, we need to create a new Task related to this newly created Case.

New Lead Created by User/System --> Flow Trigger Is Fired Automatically after Lead is Saved --> Fetch the Record of new Lead in Flow --> Create Child Case for this Lead --> Create a new Task for this Case

Please Note: In order to try and showcase a Specific Use Case, I may have overlooked some of the best practises related to Flow Development in this article. Please make sure to follow these in real world scenarios and projects. Check some really important ones below.


Let's directly jump to creating the flow.

Pre-requisites: 

Steps to Create this Flow:
  • To create flow for this requirement, first we need to select the flow of type Record-Changed Flow
  • After that we need to select the options related to When the flow is Triggered/Fired.
  • In our case, since we need an action/automation to happen only when a new Lead record is created, we will select the "A record is created option".
  • Now since we need to create the child records related to this new record, we will have to use the After the record is created option. In before the record is saved option we don't get the recordId so we cannot use that option to create associated/child records.
Most Important Point to Remember

This flow will fire After save of a record of the object(Lead) . Since we are designing an After save flow trigger, we always will have access to this Lead Record and all its fields including Id.

In our case, we will always be able to access the Id and other fields of the newly created/saved Lead record which will fire this flow.

The variable which stores this Record info is a global variable $Record. This variable can be accessed from any element within the flow and we can utilise Id ($Record.Id) property to create related child records (Cases) which we will see later.

Flow Design: This is how the completed flow will look like.
After Save Update Flows in Salesforce
This a very basic example and it has three elements.

1. Start Element : 

This is where we provide the values related to when(After save/Before save) the flow has to be fired and on which operation (insert/update or both).
We also provide the Object Name for which this flow should fire.
Check Video Below:

2. Create Record Element : Case

Here we will create a new record for Case Object. We will now use the global variable $Record which actually has all the field and values of the lead which fired this flow.
We will just map few fields to create a new Case.
Also, we will provide the Record Id of the Lead in the new lookup field of Lead for case. 
Record Id or any other field from the Lead which fired flow can be accessed like $Record.FieldNameofLead . For example: ($Record.Id, $Record.FirstName).

At the end, we also need to create a new text variable to store the Id of the newly created Case from this element. This Case Id will be used to create a task for this case.

Checkout this short video for the steps:


3. Create Record Element: Task

Similar to the last step here we are just creating a new task which will relate to the Case created in the last step.
Here, we will use the CaseId which was stored in last step to map it to WhatId field of Task.
Also, we can assign date using another global variable $Flow which has many properties including Current Date.

Tip: To provide any other date values, create a new variable using resource manager of type formula and use any relative date. For example if you needed to set up date like 2 days from today, you can use like ($Flow.CurrentDate)+2.

In the example I have used today's date directly using ($Flow.CurrentDate).

Checkout Video with steps:


And we are done! Save and activate your flow to see this in action. Just create a new Lead with name and description and you should see a new Case and Task  record created.

Please Note: Since this is a basic demo, I haven't considered/followed some best practises like condition checks and other validation check. In real world scenario, do make sure that the flows are properly tested. Also, don't forget to use fault paths for create record elements.

Checkout my blog for Before Save Update Flows here: https://accidentalcoder.blogspot.com/2020/06/before-save-update-flows.html

Checkout Latest Post on Is Changed in After Update Flows Salesforce : Is Changed in After Update Flows

See How to Use After Update Record Triggered Flows & Implement Is Changed Functionality - Use Prior Value in Record Triggered Flow to Implement Is Changed Operation

Checkout all of the Latest Salesforce Spring'21 Features : Spring'21 Flow Preview

Don't Miss Latest Posts :  CLICK HERE TO SUBSCRIBE TO THIS BLOG

Checkout Flow Examples and Tutorials : All Flow Examples

If you like this please do Share! #Learn and Share!

Enter your email address:

Delivered by FeedBurner

Comments

  1. Thank you Vibhor! These tutorials are so helpful! I'm learning flows and these breakdowns really help. It's nice to have it written out step by step as well as video form. You mentioned for best practices that you should have condition checks/validation checks as well as fault paths for create record elements. Do you have any videos/articles that show how to incorporate those into your flow? Is it possible to show how to incorporate those best practices into this flow? Also i'm assuming you created the Lead lookup field on the Case object so you'd be able to link them together in the flow using the Lead ID?

    ReplyDelete
    Replies
    1. Thanks for your Feedback and suggestions. I will write something about best practises in the near future. About Lead Id, yes you are right, Case has a field (lookup) named Lead__c to associate them. This field is used in video and steps. Let me know in case of any other questions.

      Delete
  2. Hi, I am studying for this Salesforce CPQ Certification and I wanted to know about "Custom Actions".

    ReplyDelete
  3. Your writing style is engaging and easy to follow, making it a pleasure to read.cybersecurity certification

    ReplyDelete
  4. Thanks for sharing. Great Post ! cybersecurity training

    ReplyDelete

Post a Comment

Thanks for your Feedback!

PLATFORM APP BUILDER CERTIFICATION - 78% OFF

POPULAR POSTS

Salesforce Flow Examples : Flow Use Cases and Scenarios

Flows | Use Flows to Bulk Update Records from List View in Salesforce

Flow Bulkification | Mass Update Records from Flows in Salesforce


Never Miss Latest Posts