Step By Step Guide To Creating Record-Triggered Flow in Salesforce

Update Child Records When There is a Change in Parent Record

salesforce record triggered flow

Record-Triggered Flow in Salesforce is one of the many types of Flows that you can use to automate your business processes. You can trigger the Flow when:

  • A record is created
  • A record is updated
  • A record is created or updated
  • A record is deleted

And run the Flow:

  • Before the record is saved
  • After the record is saved

With record-triggered flows you can potentially avoid writing triggers in some specific scenarios. Now you have the option of meeting complex business requirements without writing a single line of code.

Flow is the future of automation in Salesforce and is becoming increasingly powerful with every release. If you are still using Workflow Rules and/or Process Builders to build new automations in Salesforce, I urge you to switch to flows and avoid incurring technical debt. 

Spring ‘21 Release Update – Refer to the Prior Values of the Record That Triggered Your Flow

Now when an object’s record is updated, you can access that record’s earlier values in Salesforce Flow. The ‘$Record__Prior global variable contains the record’s values immediately before the Flow was run. You can use these values to check for changes in fields and calculate differences in your flow. This acts as an ‘ISCHANGED’ condition in Process Builder which we have made maximum use of in the past. So now you can take benefit of it in Flow and build logic around it. 

For this guide, we will be covering how to use the aforementioned ‘$Record__Prior global variable in Salesforce Flow. After going through this guide, within the next 20 minutes, you will learn how to: 

  • Create a Record-Triggered Flow
  • Save & Activate the Screen Flow
  • Test the Screen Flow

In this guide, we will be creating a Flow to update all the Contacts’ addresses when the related Account address changes. Earlier it could be done using Process Builder, but now you can incorporate it in your Flows using $Record__Prior’ global variable.

Liked this guide? We are now offering a complete course (self-paced) on Mastering Salesforce Flows. For more details and free preview please click here.

References & Useful URLs

25 thoughts on “Step By Step Guide To Creating Record-Triggered Flow in Salesforce”

  1. Great article, but I’m having trouble creating a flow.
    Looking to have a note pop up when a specific picklist value is selected. I keep getting an error. Any suggestions ?

    Thank you.

  2. Hi Ashish,

    I have a requirement as below
    Trigger the flow when opp product group record created
    Objects :
    Opportunity
    CW Products
    CW Product Groups
    Opportunity Product Association
    Opp Product Group Assoc

    Relationship
    Opp Product Group Assoc (MDR to CW Product Groups)
    Opp Product Group Assoc (MDR to Opportunity)
    Opportunity Product Association (MDR to CW Products) junction obj
    Opportunity Product Association (MDR to Opportunity) junction obj

    When I add/create New Opp Product Group Assoc record – flow need to trigger and get all the products from the selected CW Product Group and create Opportunity Product Association record for each product from the group and associate with Opportunity.

    How to achieve this?
    Many Thanks…

  3. Hi Ashish,

    looks like slide 19 of the PDF for creating record trigger flow is Old. Please check.
    In current versions, we have
    fast field updates ( before save) & Actions & Related records( After save)

  4. Mangesh belsare

    Hi Ashish is possible to implement a validation rule using record triggered flow where we would a use boolean variables in the assginment, set those boolean variables based of some conditions and then use those variables in the apex trigger and leverage sobject.adderror.

    1. Hi Mangesh, sounds like it should be possible technically. But then please do a PoC to confirm. But then my question will be why to use Flows at all? Since you have to use trigger to leverage sobject.adderror, just do the whole thing in Apex itself. What do you think?

  5. Ashish,

    Is it possible in a Record Triggered Flow to determine if the record needs to be created or updated? They say to have only one automtion per object so I am confused as to how to do that on a record triggered flow. You must select the trigger and run flow options in the start node.

    1. Hi Linda, I am not sure what do you mean by “Is it possible in a Record Triggered Flow to determine if the record needs to be created or updated?”. Record triggered flow fires when a record is created or updated. Can you please elaborate your question.

      1. Salesforce Idia

        Hi Ashish,
        Can we use the same flow for the Update and Create scenario by adding the check-in in the flow?
        I have a few actions for On Create scenarios and a few for update Scenarios.I want to use the same flow for Update and On Create both. How can we add the check in the decision Box?

  6. Hi,

    I have a peculiar problem where I need your advice and whether FLOW can accomplish this.

    I have created a custom object – ACP and it has a master-detail relationship to ACCOUNT.
    Now our OPPORTUNITY standard object has one mandatory ACCOUNT and we have also created 5 more custom look-up field to ACCOUNTs called Specifier, Main Contractor, Contractor, Installer and Distributor. These 4 fields are non-mandatory.

    I would like to achieve:

    1. If a record is created in ACP identifying an ACCOUNT and DATE, I would like to bring in all the opportunities (where close date = ACP DATE), in the related list or in the detail page, where this account is identified irrespective of whether it is identified on Account, Specifier, Contractor, etc.
    2. Also I would like to roll up the Opportunity Value and show in ACP (without duplicates)…so for e.g. Opportunity = A has “Widget Inc” identified as the standard ACCOUNT and also as Contractor…then the Opportunity value should only be considered one time.
    3. And also if in the future, the users create a new Opportunity identifying the ACCOUNT in #1 and Closedate as ACP Date, then this opportunity should also show in the ACP related list or detail section + the value should be added to the roll-up

    Is this something achievable with FLOW or would need Coding?

    1. Ashish Agarwal

      Hi Chandru,

      Here is how it should work.

      Since you need to do steps 1 & 2 on creation of an ACP record as well as Opportunity record, create step 1 & 2 in an auto-launched flow (This won’t be a record triggered flow). In this auto launched flow you will need to

      1. Include the ‘Get Records’ elements from Opportunity object where Close Date = ACP Date AND (Account = ACP.Account OR Contractor = ACP.Account OR Installer = ACP.Account … and so on). You can then insert these records in the child object of ACP object (you will need to create a child object, if you haven’t already)

      2. Calculate the Opportunity rollup in ACP in the same Flow. You will have to run a loop in the Flow for all the records that was retrieved in Step 1 and add the values to a variable in the loop. Then just update the field on the ACP. This will not count the values twice as you will just get one record for an account whether it is Contractor or Installer or something else.

      Now to call this auto-launched flow, you will have to use the process builder as currently you cannot call another flow from a record triggered flow.

      As I am writing this reply and thinking in my head, I think it should be possible to achieve this with the help of a flow and process builder.

      Hope this helps.

  7. Hi,
    Thank you for this helpful article.

    Question: Can we use Trigger and record triggered flows in same object?

    We are in the process of moving away from custom coding in Case Trigger by utilizing new flow functionality including record triggered flows. We were getting Too many SOQL queries: 101 error when trigger is turned on and works fine when trigger is turned off. Asking this question as we haven’t finished cleaning and recreating everything that trigger does in flow and to move what we have created to PROD and do rest of the work in phases.

    1. Ashish Agarwal

      Hi Abhi, yes, you can use the trigger and record triggered flows in same object. You just need to be mindful of the order of execution to ensure that the system behaves the way you expect it to. You may want to download the infographic from my blog post https://www.asagarwal.com/order-of-execution-rules-triggers-etc-in-salesforce-debug-log/ for this.

      You are seeing the “Too many SOQL queries” because you are running both triggers and flows. See if there is a way to optimize the flow and/or trigger. If you are using SOQL statement inside a loop, you will need to move it outside the loop to avoid getting the error.

  8. Thanks for the excellent Content Ashish. Just wrapping my head around the exciting Triggered Flows. I got this error. I understand what it is saying. Funny thing though, I can’t find the Custom Validation it is referring to

    Review the errors on this page.
    We can’t save this record because the “Update Contact Address on Account Address Change” process failed. Give your Salesforce admin these details. This error occurred when the flow tried to update records: FIELD_CUSTOM_VALIDATION_EXCEPTION: Contact must be in Account ZIP Code. You can look up ExceptionCode values in the SOAP API Developer Guide.—This error occurred when the flow tried to update records:

    1. No Worries Ashish. I found the validation rule on Contact. Deactivated it for testing purposes and everything works like a charm.
      Again thanks for the excellent content

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top