June 04, 2021

Before Save - Record Triggered Flow Scenarios



Hello Trailblazers !

Those who are familiar with Apex Trigger, must have written Before Update Trigger. Before-save updates in flows accomplish that same goal, but much more quickly because each record doesn’t get saved to the database again. Avoiding that extra save procedure means skipping another round of assignment rules, auto-response rules, workflow rules, and other customizations that take time to execute.

A flow that makes before-save updates is similar to a before trigger. In a save procedure, before-save updates in flows are executed immediately prior to Apex before triggers.

Because of their speed, it is recommended that you use before-save updates in flows to update fields on new or changed records. You can even avoid the limit for maximum CPU time on the Salesforce servers by replacing Apex code and record-change processes with before-save updates in flows.

The $Record global variable contains the values from the record that triggers the flow to run. 

Problem Statement:
When an opportunity is updated with Stage 'Closed Won', we have to update Close Date as Today's date and Type as New Customer.

How to proceed with requirement?
1. Deciding the type of flow - Record-Triggered Flow ( Before or After)
2. Choose the object whose records trigger the flow to run when they’re created or updated.
3. Use of Decision Element
4. Use of Assignment Element
5. Run the flow

Let's see it in Action

Step 1 :
Go to Setup->Search for 'Flows' -> Click 'New Flow' button to create flow

Step 2:
Select Record-Triggered Flow from popup and click Next



Step 3:
Configure Trigger as shown in image


Step 4:
Choose object and you can specify conditions requirement if you have any. 


Step 5:
Drag and drop Decision Element on to the Canvas and add conditional logic.
Here, we are simply checking new and old value of Stage using $Record.StageName & $Record_Prior.StageName 
The $Record global variable contains the values from the record that triggers the flow to run. 


Step 6:
If Decision element outcome yields to Yes, we are updating opportunity's Close Date to Today's Date ({!$Flow.CurrentDate}) and Type to New Customer. 


Step 7:
Save the flow and active it.


Step 8:
It's time to test our flow


Hope you find this post helpful. Do share your feedback!!!



3 comments:

  1. ALL LOAN SERVICES AVAILABLE

    Commercial Loans
    Personal Loans
    Business Loans
    Investments Loans
    Development Loans
    Acquisition Loans
    Construction loans
    Business Loans And many More:

    Contact Us At : unitedglobalfinancier@gmail.com
    Phone number :+17249771197 (Whatsapp Only)

    LOAN APPLICATION FORM:

    Full Name:................
    Loan Amount Needed:.
    Purpose of loan:.......
    Loan Duration:..
    Gender:.............
    Marital status:....
    Location:..........
    Home Address:..
    City:............
    Country:......
    Phone:..........
    Mobile / Cell:....
    Occupation:......
    Monthly Income:....
    Website You Heard About Us?......

    Contact Us At : unitedglobalfinancier@gmail.com
    Phone number :+17249771197 (Whatsapp Only)

    ReplyDelete
  2. BUSINESS LOAN PERSONAL LOAN HERE APPLY NOW WhatsApp +918929509036 financialserviceoffer876@gmail.com Dr. James Eric

    ReplyDelete