Skip to main content

Add a Scheduled Task to Your Flow

Learning Objectives

After completing this unit, you’ll be able to:

  • Identify how to trigger a flow on a schedule.
  • Create a scheduled path to run a record-triggered flow at a specified time.

Automation on a Schedule

By default, a record-triggered flow runs when a record changes in a specified way. But you can delay that automation by using a scheduled path. Actions on a scheduled path are triggered when the specified record change occurs, but run after a period of time. This can be minutes, hours, days, or even months after the record change. They can also be scheduled for a period of time before or after a field on the triggering record. For example:

  • 6 hours after a case is created
  • 2 days after the renewal date for an account
  • 1 month before the warranty expiration date

Business Requirement

Let’s expand our opportunity flow to include a new business requirement: Remind the opportunity owner to follow up with the account owner 5 days after the opportunity closes. 

Note the timing “5 days after”. To create that 5-day delay in the flow, we add a scheduled path. In the scheduled path we create a task for the opportunity’s owner.

Before You Start

You should define your org's Default Workflow User before you start creating scheduled paths. This setting tells Salesforce which user runs the flow's scheduled path. This setting might already be set in your production org, but it’s a good idea to confirm it. Make sure that this setting is correct in the Trailhead Playground you’re using for this badge before you create a scheduled path.

Set the Default Workflow User on the Process Automation Settings page in Setup.

The Process Automation Settings page. Default Workflow User is Flo Smith.

Configure Scheduled Paths

  1. Under Flow Definitions, select the Triggered Flows list view.
  2. In the Flow Label column, click Closed Won Opportunities. The flow opens.
    ""
    Because we chose Actions and Related Records when we created the original flow, we can add our scheduled path directly in this flow. You can use scheduled paths only when the flow uses the Actions and Related Records option.
  3. Click Add Scheduled Paths (Optional).The Scheduled Paths panel. Fields include Path Label, API Name, Time Source, Offset Number, and Offset Options.
  4. For Path Label, enter 5 Days After Close. The API Name field is automatically updated to X5_Days_After_Close.
  5. For Time Source, select Opportunity: Close Date.
  6. For Offset Number, enter 5.
  7. For Offset Options, select Days After.

Add a Task

Now let’s add the task to remind the opportunity owner to follow up with the account owner five days after the opportunity closes.

  1. In the 5 Days After Close path, click Add Element.
  2. Scroll to the Data section and click Create Records. The New Create Records window opens.
    The New Create Records panel. Fields include Label, API Name, Description, How Many Records to Create, and How to Set the Record Fields.
  3. For Label, enter Personalized Welcome Task. The API Name is automatically updated to Personalized_Welcome_Task.
  4. For Description, enter Creates a task for the Opportunity owner to coordinate with the Account owner on their new account.
  5. For How to set record field values, select Manually.
  6. For Object, select Task.

Set Conditions

  1. Under Set Field Values for the Task, set the task subject:
    • Field: Subject
    • Value: Coordinate with Account Owner
  1. Click Add Field.
  2. Describe the task:
    • Field: Description
    • Value: Devise an action plan to welcome the new customer from your opportunity
  1. Click Add Field.
  2. Associate the new task with the opportunity that triggered the flow:
    • Field: Related To ID
      The Related To ID field can refer to the ID of any related non-human object. It represents something other than a person, such as an account, opportunity, campaign, case, or custom object. To refer to a person object, such as a contact or lead, use Name ID.
    • Value: Triggering Opportunity > Opportunity ID
      Remember, data from the record that triggered the flow is stored in the Triggering variable. To reference the record itself, drill down from Triggering Opportunity to the Opportunity Id field.
  1. Click Add Field.
  2. Set the owner of the new task to match the owner of the opportunity that triggered the flow:
    • Field: Assigned To ID
    • Value: Triggering Opportunity > Owner ID (select the Owner ID that doesn’t have a > at the end of the line)
  1. Click Add Field.
  2. Set the task due date:
    • Field: Due Date Only
    • Value: Running Flow Interview > CurrentDate (You usually use a formula resource to dynamically set the activity date to a date in the future, but for simplicity in this module, we use a global variable that always sets the current date.)
  1. Click Save As New Version, then click Save.

Adding the scheduled task is complete! Now let’s test to make sure that it's working properly.

Debug the flow

  1. Click Debug. The Debug flow window opens.Debug flow screen. Fields include Select Path, Debug Options, and Run the Flow As if the Record is Created or Updated.
  2. For Path for Debug Run, select 5 Days After Close.
  3. For Debug Options, click Skip start condition requirements.
  4. For Run the Flow As If the Record Is, keep Created selected.
  5. For Opportunity, select the same organization you used in unit 1 to run the flow against. (This example uses Grand Hotels Emergency Generators.)
  6. Click Run.
    The flow is debugged. If it ran successfully, the line connecting the elements is bolded and dark blue.
  7. Click Back (Back) to exit Flow Builder.

Success! Using both an immediate path and a scheduled path, you’ve created a flow that automatically manages your high-value opportunities.

the completed flow with 2 branches, run immediately and 5 days after.

Tell Me More

You can expand this flow to include more criteria and actions. If an opportunity doesn’t meet the conditions (greater than 25000 and Closed Won), do something different. For example, check whether a high-value opportunity is Closed Lost. If it is, automate different actions. But don’t stop there. What record-triggered flows can you build on other objects?

Resources

Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback