A Christmas Present – Schedule an Autolaunch Flow!

A Christmas Present – Schedule an Autolaunch Flow!

Last Updated on February 10, 2022 by Rakesh Gupta

Let us continue with my Salesforce Flow, ‘Getting Started’, series. We discussed how different types of Flows enable you to minimize code usage. Until the Winter’20 release, Scheduling Autolaunched Flows was out-of-scope. No more!

As we all know, before the Winter’20 release, autolaunched Flows could only be launched using Process Builder or Apex. But, that was before! Let us open our present, shall we?

What are Scheduled flows?

Before we unwrap, let us understand what Scheduled Flows are. Scheduled Flows are not triggered by an Event on the data; they simply run when a scheduled time arrives.

Scheduled Flows run as follows:

  • Once (On a particular date and time)
  • Daily (On a particular date and time)
  • Weekly (On a particular date and time)

The best part about Scheduled Flows is that it allows you to specify an Object and a filter to only run for a set of records.

Blog 6.2

Remember, when a Flow starts, a Flow interview runs for each record that matches the filter criteria – no looping is required. The matching record is stored in the $Record global variable, so you can reference the variable, or its fields, throughout your flow.

Why do we need Scheduled flows?

Do you have Flows that are launched from Process Builder every time a record is created or edited – even though you need them to run only once a day or once a week (like Scheduled Apex provides)? If you had such requirements before winter’20 release, you would have to write Apex code. Or, you would have messed-up your Salesforce org with many unwanted Processes or Flows.

Scheduled Flows provide you the flexibility to run auto-launched Flows on scheduled time (Like daily, weekly or once). Yes, now you have one more way to solve your business needs using clicks not code!

What are some use cases of Scheduled flows?

Thankfully, there are many. Let me list a few:

  1. Deactivate users on their last day at work.
  2. Create new users ahead of time and send a welcome email with a new password on the day of on-boarding.
  3. You may also schedule Flows to cleanse data.

Business Use Case

Edward Backhouse is working as a System administrator at Gurukul on Cloud (GoC)GoC is faced with data integrity issues. Sales reps are not updating Opportunities proactively. This negligence, on the part of Sales Reps, has generated thousands of open Opportunities in the System. 

GoC’s upper management wants to address the issue by running a nightly process to update Opportunities to Closed Lost if it matches the following criteria:

  • Opportunities’ Account is marked as out-of-business (which can be identified through a checkbox field on the Account name, Out of Business).
  • Opportunities’ Close Date was before 90 days from today’s date.

Solution for the above business requirement

To solve this requirement, we will only a few ingredients – including, Salesforce FlowCustom field (Out_of_Buesiness__c) on the Account object. 

Before trying to understand the technical aspect of the solution, let us spend some time to understand the general flow of our solution at a very high level. Please spend a few minutes to go through the following flow diagram and understand it.

Screen Shot 2019-11-13 at 7.36.55 AM

Using Scheduled Flow, you can streamline the Flow’s logic and create a better performance Flow. Scheduled Flows allow you to specify a filter on an Object and run only for a set of records. 

Let us use Salesforce Flow to solve the above business requirement. Perform the following steps to create the solution using the new Flow Builder: 

  1. Log-in into your developer org. 
  2. Create a Custom Field (Out_of_Business__c) on the Account object. 
  3. Navigate to Setup (Gear Icon) | Setup | Process Automation | Flows.
  4. You’re now on the Flow management page. Based on your current org setting, you may see the following buttons: Lightning Flow 5.1
  5. Now click on the New Flow button, it will open a pop-up. Perform the following actions on the pop-up screen: 
    1. Autolaunched Flow as Flow Types
    2. Once done, click on the Create button.Blog 6.1
      Now it will redirect you to Flow Builder.
  6. Next, we will use the Start Element to filter out Account records and, set schedule time, including other details. Double clicks on the Start Element. Follow the steps as shown in the video:
  7. The next step is to create a formula to figure out a date that is exactly ninety days before today (the day when flow runs). Click on the Manager | New Resource and creates a formula – as shown in the following screenshot:Blog 6.4.jpg
  8. Next, we will use the Record update element to update the open opportunities which have a close date that is exactly ninety days before today (the day when flow runs). Drag and drop a Record update element onto the Flow Builder – Check out the video for step-by-step instructions:
  9. In the end, Edward’s Flow will look like the following screenshot:Blog 6.6
  10. Once you’re done, Save the flow and name it Manage Open Opportunities for OOB accounts with Type: Autolaunched Flow. Do not forget to activate the Flow by clicking on the Activate button.
  11. Woohooo, you have just created a scheduled Flow using Flow Builder

Monitor your schedule flow

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

  1. Navigate to Setup (Gear Icon) | Environments | Jobs | Scheduled Jobs.
  2. Now look for your Scheduled Flow displaying information as shown in the following screenshot: 
    Blog 6.7.1.jpg
  3. Use Del link to delete the Scheduled Flow job from the queue.

It’s time to test the Process

To test the Scheduled Flow, I’ve updated the schedule run time to 11/12/2019 12:40 AM. At this time, the Scheduled Flow ran and updated the Opportunity Stage to Closed Lost. Attached please find the screenshot for your reference:

Blog 6.8

Monitor your schedule flow

  • The Automated Process user runs Scheduled Flows.
  • A Scheduled Flow can run only from a schedule.
  • If a Scheduled Flow is deleted from the Scheduled Jobs page, the Flow’s status remains active.
  • The Start Time field value is based on the org’s default time zone.
  • When you define multiple filters, the filter logic usually defaults to AND. However, if multiple filters have the same field selected, and use the equal operator, the filters are combined with OR. For example, your filter checks whether an Opportunity Stage equals Closed Won (1); Stage equals Closed Lost (2); and, Closed Date equals today (3). At run time, the filters are combined to (1 OR 2) AND 3.
  • You have a per-org 24-hour limit for the number of Scheduled Flow executions at the scheduled start time. The org limit is the greater number between 250,000 records or the combined total of 200 records per user license. When a Flow is scheduled to start, make sure that its schedule and conditions don’t cause your org to go over the limit

I hope you learned something valuable today and understood how to use schedule flow! Who knew? that learning could be so much fun!! 

–> Please feel free to add constructive comments and insights to the blogs.

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

Preferred Timing(required)

3 thoughts on “A Christmas Present – Schedule an Autolaunch Flow!

  1. Hi Rakesh,

    I have to schedule a flow to send an email to the user if he has not logged in in the last 10 days.Will bother him in another 10 days if he does not listen

    Here are the steps:-

    1)Queried all active users and stored their last name,email in the collection variable of type User.
    2)Loop thorugh the user records.
    3)Created a variable to store the difference between Todays()-last login date(Which is a formula).

    Today()-10

    4)Decision:-LoginDate Less than or equal to Today()-10

    then send an email to the user

    Will this formula be fine or Do i need to make some changes to it.

    Willl u please advice,Thanks

Leave a Reply

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

Discover more from Automation Champion

Subscribe now to keep reading and get access to the full archive.

Continue reading