Adding a Time-dependent Action to Record-Triggered Flow

Adding a Time-dependent Action to Record-Triggered Flow

Last Updated on April 17, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

How do you schedule a time-based action using Salesforce Flow?

Objectives:

After reading this blog, you’ll be able to: 

  • Understand the basics of scheduling an action using Salesforce Flow
  • Add a Scheduled Paths action in After-save Record-Triggered Flow
  • Learn how to automate the flow which requires users to perform certain activities after x Hours or Days
  • and much more

Business Use case

Corey Eridon is working as a System Administrator at Gurukul on Cloud (GoC). He received a requirement to auto-update the Asset Description (with the sentence “Update the Serial Number“) field after 1 day of its creation if the Asset’s Serial Number is blank.

Automation Champion Approach (I-do):

Workflow Rule allows you to update the fields from the same object or parent object (In the case of master-detail relationship only). Whereas Salesforce Flow allows you to update the record from the same object or records from the child object or records from the parent object (either Master-detail or Lookup relationship). 

As we are moving away from the Workflow Rule and Process Builder, Corey should use Salesforce Flow. To solve this requirement, we will use the After-save Record-Triggered Flow. Check out this article to understand why we are using after-save record-triggered flow for this scenario.

Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes going through the following Flow diagram and understand it.
Let’s begin building this automation process.

Guided Practice (We-do):

There are 3 steps to solve Corey’s business requirement using Record-Triggered Flow. We must:

  1. Define flow properties for record-triggered flow
  2. Add a scheduled path
  3. Add an Update Records element to update the asset description 

Step 1: Define Flow Properties

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Record-Triggered Flow option, click on Create and configure the flow as follows:
    1. Object: Asset
    2. Trigger the Flow When: A record is created
    3. Set Entry Criteria
      1. Condition Requirements: All Conditions Are Met (AND)
        1. Row 1:
          1. Field: SerialNumber 
          2. Operator: Is Null
          3. Value: {!$GlobalConstant.True}
    4. Optimize the Flow For Action and Related Records
  5. Click Done.

Step 2: Salesforce Flow – Add Scheduled Paths

The purpose of using a scheduled path is to update the asset description after 1 day. 

  1. Under Start, select Add Scheduled Paths (Optional).
  2. Under SCHEDULED PATHS, click on the  New Scheduled Path.
  3. Under Scheduled Path Details, enter the Label the API Name will auto-populate.
  4. Time Source: Asset: Created Date
  5. Offset Number: 1
  6. Offset Options: Days After
  7. Advanced Options
    1. Batch Size: 200
  8. Click Done.

Step 3: add action – update records 

The next step is to update the asset description. We will use the Update Records element. 

  1. On Flow Designer, below the 1 Day After node, click on the +icon and select the Update Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. For How to Find Records to Update and Set Their Values select Use the asset record that triggered the flow
  4. Select None – Always Update Record
  5. Set Field Values for the Opportunity Records
    1. Row 1:
      1. Field: Description 
      2. ValueUpdate the Serial Number 
  6. Click Done.

In the end, Corey’s Flow will look like the following screenshot:

Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 54
  5. Interview Label: Update Asset Description {!$Flow.CurrentDateTime}
  6. Click Save.


Almost there! Once everything looks good, click the Activate button.  

Note:- Before you activate your flow, you will want to make sure that you have assigned data in the correct format because Salesforce Flow obeys validation rules. If some fields are required by using validation rules, then make sure you have added those fields. Conversely, if some fields are required on the page layout, you can ignore those fields. 

Monitor Your Schedule Flow

To monitor Flows that are scheduled, navigate to the following path: 

  1. Navigate to Setup (Gear Icon) | Environments | Monitoring | Time-Based Workflow.
  2. Click Search.
  3. Now look for your Scheduled Flow job displaying information as shown in the following screenshot:
  4. Use the Delete button to delete the time-based Flow job from the queue.

Formative Assessment:

I want to hear from you!

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

25 thoughts on “Adding a Time-dependent Action to Record-Triggered Flow

  1. Hi Rakesh,

    We have a limit that the total number of flow interviews that are executed per hour is 1000.

    If flow interviews are more than 1000, then I believe they will be queued and gets executed in the next hour. My question is- can I view these pending interviews also in ‘paused and waiting interviews’ section? or is this section only for time based scheduled actions ?

    1. Ideally, it should be queued and gets executed in the next hour (I will suggest you, get in touch with Salesforce support for more details)
      I think yes, you can view in ‘paused and waiting interviews’ section

      1. Thanks for the reply.
        Can you also tell me if there is any way we can figure out the start and end time of a running process?

  2. Hello Rakesh, Really Appreciate your work in the automation concepts of the platform. I would like to know if the time dependent actions that are created on Process builder and on workflow behave differently. I have tried looking up on forums but didn’t find a clear answer for that. Any help or Information would be really helpful.

      1. I remember while studying about the differences about workflows and process builder that they behave a bit differently when it comes to time dependent actions. I don’t exactly remember the article or the blog where I read that. I just wanted to know if they behave in the same way or differently. As this blog has in detail content about automation in salesforce, I thought you are be the right person to shoot this question to.

  3. Hi, Firstly I love your contribution to the Salesforce community. I come here for inspiration and ideas!

    So I am trying to contribute myself. I had a great idea to allow admins to schedule repeating process builds/workflows by using the scheduled report feature.

    Declarative Scheduler – use the reporting engine and subscribe feature to update records in report on a daily/weekly/monthly schedule. I have created a generic apex class to help admins tackle this problem. It utilises reports to define, filter and schedule updates. 

    -Create a report with the record id in column 1 and a datetime field in column 2
    -Add the filters you like
    -Click subscribe. Then select a custom action.
    -Set up when you would like these records to update and then schedule away
    -On the scheduled time the datetime field will be updated.
    -Set up a process builder to fire when that field changes. And voilla you have a repeating schedule.

    See the first draft here. I would love your ideas and suggestions:
    https://github.com/dthowell/DeclarativeScheduler

  4. Hi Rakesh,

    What if Criteria changes while a Flow is paused? Is it supposed to cancel it (like it would for a time-based workflow rule)?

    I am using Process Builder to send Email Alerts 7 days after criterias are met, and Email Alerts are still getting sent even when the criteria changes between day 1 and 6 and no longer meet the rules.

    Thanks!

    1. • For processes that are set to run when a record is created or edited, scheduled actions remain in the queue only as long as the criteria for those actions are still valid. If a record no longer matches the criteria, Salesforce removes the scheduled actions for that record from the queue.
      • For processes that are set to run when a record is created, Salesforce never reevaluates the record with that process. Scheduled actions remain in the queue, even if the record no longer meets the associated criteria when the scheduled actions are executed.

  5. Hi,

    I did exactly the same. My time based action was to kick in after 4 days on cases, if the status is still New. I am posting a chatter notification. I did a test run in my sandbox, and it worked well, for all cases! But in production, it stopped working. As in all the cases were created and had a status change in the next 2 days of creation, but the time based action still kicked in. Isn’t it supposed to be deleted once it is out of the criteria (just like time based WFR)? Please help, because it did work in my sandbox, and not in production it did not, and it has alerted a bunch of users unnecessarily.

      1. Please go through this article
        https://help.salesforce.com/articleView?id=process_limits_scheduled.htm&type=0&language=en_US

        –> For processes that are set to run when a record is created or edited, scheduled actions remain in the queue only as long as the criteria for those actions are still valid. If a record no longer matches the criteria, Salesforce removes the scheduled actions for that record from the queue.

        –>For processes that are set to run when a record is created, Salesforce never reevaluates the record with that process. Scheduled actions remain in the queue, even if the record no longer meets the associated criteria when the scheduled actions are executed.

Leave a Reply

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