Loading

Create a Flow to Expire Opportunities After a Set Date

Veröffentlichungsdatum: Mar 3, 2026
Beschreibung

In this article, we focus on configuring a Flow to automatically close Opportunities after a specific date to maintain a clean and accurate sales pipeline. As an example, we will demonstrate how to set up automation that updates Opportunities based on their creation date or another relevant date field to prevent outdated records from impacting pipeline visibility.

Lösung
  • Given the fact that the automatism will only update the Stage of concerned to be expired Opportunities, and that the process will concern a limited number of Opportunities, every time it will be fired, no-code Flows are the most appropriate solutions for this use case
  • We may leverage

         a. Either a scheduled Flow running every day, querying the Opportunities to close into a collection, and closing this list of Opportunities

         b. Or a Scheduled Path in a record triggered Flow, setting up a specific closing path, into a Flow that is fired when the Opportunity is created

  • The Schedule-Triggered Flow will consider all records that are present in the database, meeting the start entry conditions. However, the Record-Triggered Flow will only consider the Opportunities records created after the Flow activation. It will not consider the record created or updated (according to the requirements) before the Flow is activated
  • Make sure to take this important detail in consideration when choosing the right solution

Option 1: Build a Schedule-Triggered Flow running every day

  • The problem with Scheduled Flows is that we cannot get filter on dynamic date values in the Start element. We can only filter on static date values. That would make us request all Opportunities, in order then to filter on a small subset of them, which is not very optimal

  • As a workaround, to begin with this solution we need first to create a Formula field, on the Opportunity object, with a Boolean Formula that will identify if the Opportunity record is concerned by the expiration process

         a. Go to Setup, click on the Object Manager tab, look for Opportunity object in the object list, and click on the Opportunity link

         b. Click on Fields & Relationships from within the left pane

         c. Click on New button

         d. Select Formula data type, and click Next

         e. Select Checkbox return type, choose Field Label and API Name and click Next

  • In the Formula input field, type the requested Formula that will define a to-be expired Opportunity, accordingly to your business

         a. For example, this first Formula will return True for all Opportunity records whose CreatedDate is older than 60 days

NOW() >  CreatedDate + 60

         b. For example, this second Formula returns True for all Opportunities whose CloseDate is in the past

TODAY() >  CloseDate
  • Naturally, you can adapt one of these Formulas to match a specific Opportunity lifetime requirement

        a. Check Syntax to validate that there is no syntax error, and Click Next

        b. Grant access to the proper Profile or Permission set according to your configuration. Make it at least visible for the System Admin profile

        c. Click Next add the fields to the relevant layouts if required. This step is optional, and you may skip adding the fields to the layouts if not needed

        d. Click Save

  • Then, create the Schedule-Triggered Flow that will request Opportunities whose technical expiration flag is True

        a. Go to Setup, type Flows in the Quick find box

        b. Click New Flow

        c. Click on View All Automations below Scheduled Automations

       d. Select Schedule-Triggered Flow

       e. Either fill in the detail page, on the right of the screen, or click Set Schedule. Set the Flow to run Daily

       f. Then Click On + Choose Object and choose Opportunity object. Add the filter on the new Boolean field we have just created. It will restrain the Scheduled Flow to execute only on the subset of to be expired Opportunities

 

       g. In our case, the Start element will only filter open Opportunities, not closed, with the proper Boolean flag where the Expiration Status is True

       h. Click on the + between the Start and End blocks, and select the Update Records element

       i. Configure the Assignment / Update action you want to achieve for the concerned records here the Status is switched to Closed Lost

       j. Activate the Flow

      k. Wait for the Scheduled Flow to run to see if your concerned Opportunities have been updated

Option 2: Add a Scheduled Path on a Record-Triggered Flow running on Opportunity record save

      a. Go to Setup, type Flows in the Quick find box

      b. Click New Flow or use an existing Flow on the same object, if one is adapted for such usage

      c. Click on View All Automations Below Triggered Automations

      d. Select Record-Triggered Flow

      e. Select Opportunity as a triggering object, when a record is created or updated. Optimize the Flow for Actions and Related Records to be able to configure a Scheduled Path on it

      f. Click on the + Add Scheduled Path which is optional to configure a Scheduled Path within your Record-Triggered Flow. A Run Immediately label is added to the current path, and a second branch is created below the Start element

        

      g. Rename the new Scheduled Path branch to make it clear that it concerns a Scheduled Path, for example, 10 days after CloseDate

      h. Then, choose the reference date, among all these that are present on the triggering record, and the Flow interview date

      i. Then select the negative or positive offset to apply to this reference date, which in this case is10 days after the triggering record CloseDate

    

      j. In this example, I need to add actions on each one of my branches, to be able to save this Flow. It could be any relevant actions or Flow element to leverage on Opportunity creation / update use cases

     k. For example, on the Run Immediately branch, I have added a Post to Chatter action

     l. The message of this action is set with a simple text-typed Formula resource, that should be created from the resource pane. click on the Toggle Toolbox icon > New Resource > Select Formula as a Resource Type

      m. The triggering Opportunity id can be used as the record target id for the Post to Chatter action

      n. In the second branch, running asynchronously, I have added an Update Record element to update the Stage of the triggering Opportunity

      o. As this asynchronous branch content can run a few minutes, hours, or days, after the record has been saved or updated, do not forget to test your record before running the actions configured to run asynchronously. Here, only an Update Records element in the case below, 10 days after the theoretical ClosedDate is over, the branch considers only open Opportunities by setting Filter Conditions to ensure the triggering Opportunity is not closed, then updates their stage to Closed Lost 

      p. Save and Activate the Flow

 

      q. To validate that the Scheduled Path is well considered, create a sample Opportunity

      r. See first if the record has got a new Chatter message in its Chatter tab

      s. Then check that the Scheduled Path is well planned 10 days after the Opportunity’s CloseDate. Navigate to Setup > Environments > Monitoring > Time-Based Automations in the Setup Quick Find Box

      t. When you click the Search button, you will see a table displaying all Time-Based Automations currently in progress and waiting to run. Filters may or may not be applied depending on your instance and the number of Time-Based Automations running

      u. Here, you can check that the Scheduled Date, for the Scheduled Path execution, is planned 10 days after the Opportunity Close Date

___________________________________________________________________________________________

Written by: Eric BURTÉ | Forum Ambassador

Based in France, Eric Burté is Head of Salesforce and AI, within DEVOTEAM Group. As a Salesforce Expert Director, Salesforce Application and System Architect, 19 x Salesforce certified, and 2025 Agentblazer Legend, Eric works with Salesforce project teams, to support them on the design, architecture, build and delivery of their Salesforce projects, and works with his clients in assessment project context, Salesforce ‘Center of Excellence’ teams management, or Design Authority approach implementation.
Answers Leader in Trailblazer Community, Eric has been designated as a Trailblazer Community Forum Ambassador in 2024 & 2025.

Submissions reflect only the opinions of the user who made available the Submission and not the opinions of Salesforce, regardless of whether the user is affiliated with Salesforce, and may contain or constitute products, services, information, data, content and other materials made available by or on behalf of third parties ("Third Party Materials).  Salesforce neither controls nor endorses, nor is Salesforce responsible for, any Third  Party Materials, including their accuracy, validity, timeliness, completeness, reliability, integrity, quality, legality,  usefulness or safety, or any applicable intellectual property rights. Any Submissions made available through any message board or forum in response to posted questions, or that otherwise purports to answer any questions, including any questions about Salesforce or Programs, are made available for your general knowledge only and should never be relied upon as answers to your specific questions (even if an answer is marked as a “best” answer or with any similar qualifications). You should always contact Salesforce support for answers to your specific questions. Salesforce has no control over Submissions, and is not responsible for any use or misuse (including any distribution) by any third party of Submissions. 

If you have questions, tap into the wisdom of our entire Trailblazer Community here: https://trailhead.salesforce.com/trailblazer-community/feed

 

 

 

 

 

 

 

 

 

 

 

Nummer des Knowledge-Artikels

005315440

 
Laden
Salesforce Help | Article