DEV Community

Cover image for Don't Forget Closed Lost Deals: Build a Win-Back Review Queue in Salesforce with a Scheduled Flow
Juan Manuel Garrido
Juan Manuel Garrido

Posted on

Don't Forget Closed Lost Deals: Build a Win-Back Review Queue in Salesforce with a Scheduled Flow

In 2001 my company, EGA Futura, lost a deal we had been negotiating for two years: having our software sold together with Epson fiscal printers through one of the main distributors in Argentina. In 2003, two years later, we closed a nationwide distribution deal for our software alongside those same fiscal printers, and it brought in thousands of new customers. I wrote the full story (in Spanish) on EGA Futura Discover.

We were not on Salesforce back then. But the lesson maps cleanly to a CRM problem I still see in many Salesforce orgs: once an Opportunity hits Closed Lost, it drops out of every pipeline report and nobody looks at it again. If the deal comes back, it is by luck.

Here is a small, declarative setup that turns lost deals into a review queue. No Apex required.

The data you need

Two custom fields on Opportunity:

Field Type Purpose
Loss_Reason__c Picklist Why it was lost (Price, Chose competitor, No budget, Postponed, No response, Other)
Revisit_On__c Date When someone should look at it again

Make the reason mandatory on close with a validation rule:

AND(
  ISPICKVAL(StageName, "Closed Lost"),
  ISBLANK(TEXT(Loss_Reason__c))
)
Enter fullscreen mode Exit fullscreen mode

Then set Revisit_On__c with a record-triggered flow (after save, only when the record is updated to meet the condition StageName = Closed Lost). A formula like ADDMONTHS({!$Record.CloseDate}, 12) works as a default; you can branch by reason (24 months when they chose a competitor, 6 when the project was postponed).

The scheduled flow

Create a Schedule-Triggered Flow:

  1. Start: runs daily, object Opportunity, conditions:
    • StageName equals Closed Lost
    • Revisit_On__c equals {!$Flow.CurrentDate}
  2. Create Records (Task), one per Opportunity in the run:
    • WhatId = {!$Record.Id}
    • OwnerId = {!$Record.OwnerId}
    • Subject = Revisit lost deal: {!$Record.Name}
    • ActivityDate = {!$Flow.CurrentDate}
    • Description = reason and amount, so the owner does not have to open three screens

A scheduled flow processes the matching records in batches, so you do not need a Loop for this. If the owner is inactive, the Task insert fails for that record; route those to a queue or a manager with a Decision element before the Create Records step.

If your org does not accept $Flow.CurrentDate in the start conditions, filter on StageName only and put the date comparison in a Decision element.

A query to check the queue

Before turning the flow on, see what it would pick up in the next month:

SELECT Id, Name, Account.Name, Amount, CloseDate,
       Loss_Reason__c, Revisit_On__c, Owner.Name
FROM Opportunity
WHERE StageName = 'Closed Lost'
  AND Revisit_On__c = NEXT_N_DAYS:30
ORDER BY Revisit_On__c
Enter fullscreen mode Exit fullscreen mode

And one to see whether lost deals actually come back:

SELECT Original_Opportunity__r.Loss_Reason__c, COUNT(Id) wins
FROM Opportunity
WHERE IsWon = true
  AND Original_Opportunity__c != null
GROUP BY Original_Opportunity__r.Loss_Reason__c
Enter fullscreen mode Exit fullscreen mode

That second query assumes one more field: a lookup Original_Opportunity__c on Opportunity.

Do not reopen the old Opportunity

When a lost deal comes back, create a new Opportunity and point Original_Opportunity__c to the lost one. Reopening the old record rewrites history: your 2001 report would say you won, and you lose the only data that tells you how many lost deals return and after how long.

The same goes for deleting old Closed Lost records to "clean" the pipeline. That history is the asset.

Why bother

Two years of meetings looked wasted in 2001. They were not, but nothing in a system would have told us. A reason, a date and a daily flow are a cheap way to make sure the next comeback is not left to memory.

At EGA Futura we build a native ERP for Salesforce, so sales, invoicing and inventory live in the same org. The Spanish companion piece on Hashnode covers the validation rule, history tracking and reports in more detail.

Juan Manuel Garrido, founder of EGA Futura

Top comments (0)