The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Recommended

Build a win-back review queue for Closed Lost Opportunities with a scheduled Flow (opens in a new tab)

You will learn how to add a loss reason and revisit date to lost Opportunities, have a Scheduled Flow create follow-up Tasks on those dates, and keep lost deals linked to any later win.

Why read this

The approach needs no Apex.

  1. Require a loss reason on Closed Lost
  2. Set Revisit_On__c with a Record-Triggered Flow
  3. Scheduled Flow runs daily on revisit date
  4. Create a Task assigned to the owner
  5. Route inactive owners to a queue or manager
How a Closed Lost Opportunity moves from lost deal to a daily revisit Task

The author argues that Opportunities marked Closed Lost fall out of pipeline reports and are rarely revisited, so lost deals return only by chance. He proposes a declarative setup that turns them into a review queue.

The setup adds two Custom Fields on Opportunity, Loss_Reason__c as a picklist and Revisit_On__c as a date. A Validation Rule requires a loss reason when the stage is Closed Lost. A Record-Triggered Flow sets the revisit date, with a default of 12 months after the close date that can vary by reason.

A Schedule-Triggered Flow runs daily on Opportunities that are Closed Lost and whose revisit date is today. It creates a Task for each record, assigned to the owner, with a subject, the activity date and a description containing the reason and amount. Inactive owners will cause failures, so the author suggests routing those records to a queue or manager with a Decision element. Before activating the flow, he recommends running a SOQL query to preview the next 30 days of revisits.

The author also suggests a lookup field, Original_Opportunity__c, to link a new Opportunity to the lost one when a deal returns. He warns against reopening old records or deleting Closed Lost ones, since that erases the history needed to measure how many lost deals come back and after how long. A second query groups won deals by the loss reason of their original Opportunity to test this.

Read the original at dev.to (opens in a new tab)

Worth reading?

Recommended

Staging an AI agent's Salesforce access in three permission levels (opens in a new tab)

You will learn a staged way to grant an AI agent access to Opportunity data: read first, then propose tasks, then write a few fields.

Why read this

You will also see how the staging exposes data gaps and undocumented exceptions before any record changes.

  1. Level 1: read Opportunity and activities
  2. Level 2: propose Tasks for the owner
  3. Level 3: write a few fields
The agent gains write access only after each lower level works

The author describes an AI agent that reviews Salesforce Opportunities with no activity for 30 days, checks recent interactions and prepares follow-up actions. The design question is what the agent is allowed to do, and the author splits this into three permission levels that the agent moves through only once the level below works.

At level 1 the agent only reads Opportunity, its activities and OpportunityHistory. It runs under its own integration user with a Permission Set limited to the objects and fields it needs, and any tool layer such as MCP exposes read tools only. Every query is logged with its filter. This level shows whether no movement is defined well, since LastActivityDate, stage changes in OpportunityHistory and LastModifiedDate give different lists, and LastModifiedDate also moves when a Flow, integration or bulk load touches a record.

At level 2 the agent proposes rather than edits, creating a Task for the Opportunity owner with the suggested next step, WhatId set to the Opportunity, OwnerId set to the owner and a subject prefix that marks it as agent-written. A person decides what happens. This level reveals exceptions, such as deals deliberately paused, which the agent cannot know unless they are stored in a field, and data gaps, such as calls logged outside Salesforce. The author suggests counting open Opportunities with no LastActivityDate and fixing the data before moving on.

At level 3 the agent writes a few fields, such as a next step or follow-up date, with field-level security keeping the rest read-only. Exceptions are encoded in the query, for example skipping records with a future resume date, and changes are tested in a sandbox with realistic data. Because the agent has its own user, LastModifiedById and field history separate its changes from people’s. The author’s point is that a wrong filter at level 3 corrupts every matching record at once, so the staging keeps mistakes cheap.

Read the original at dev.to (opens in a new tab)

Worth reading?