Loading

Mark Salesforce Sales Account Inactive if No Opportunity for X Days

Udgivelsesdato: Apr 20, 2026
Beskrivelse

To automatically deactivate accounts with no recent opportunity activity, implement a Scheduled Flow to update the account status based on custom time thresholds.

To track the account's status, you can create a status picklist field on the Account object with two values: Active and Inactive. Else, you can create a checkbox field.

Løsning


Step 1: Create a Roll-up Summary Field on the account object that will show the most recent closed date of the opportunity where Stage equals Closed Won using the MAX option on the Roll-up Summary Field. Set Field to Aggregate to Close Date.

Rollup.png

Step 2: Create a formula field on the Account object that returns a number (0 decimal) which is the number of days. The formula checks if the account has at least one closed won opportunity, then returns the number of days since the opportunity closed (using the rollup summary field created in Step 1. If no closed won opportunity exists, then use the account created date and return the number of days since the account was created

Example Formula: 

IF(
ISBLANK(Most_Recent_Closed_Date__c),
TODAY() - DATEVALUE(CreatedDate),
TODAY() - Most_Recent_Closed_Date__c
)


Step 3: Create a Scheduled Flow that should be scheduled to run daily and put the criteria that if Closed_Won_Opp_Since__c  Greater Than 180 and the Operator DOES NOT EQUAL Inactive then update the account status to Inactive. You can set the Start Date, Start Time & Frequency of the flow to any preferred value.

Choose Object.pngSet Schedule.png

Step 4: Set criteria for the records that should enter the flow and update the Account Record value to Inactive

Edit update.png


All done! Now this Scheduled Flow will run daily and check if any active opportunity has no closed won opportunity created for 180 days, then update the account status to inactive
_____________________________________________

Written By: Waqar Hussain | Salesforce Answers Leader
Waqar is a certified System Architect at EinsTeam and has 8+ years of experience in the Salesforce domain. He is focused on delivering Salesforce's services to ensure organizations are getting the most out of the Salesforce Platform. He is also very active in the Trailblazer Community & Salesforce Developer Community. 

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
Vidensartikelnummer

000393490

 
Indlæser
Salesforce Help | Article