Sub topic 1
What an Opportunity Is and Where It Fits
Prerequisites
This chapter assumes you already know the following:
- Basic Salesforce navigation: apps, tabs, list views, and record pages.
- What Accounts, Contacts, and Leads are, and how they relate.
- The difference between standard and custom objects and fields.
- The basic idea of a sales pipeline: a set of deals at different points on the way to a close.
You do not need to know how to configure stages, sales processes, or record types yet. Later chapters cover those.
What an opportunity represents
An Opportunity is a standard Salesforce object. Each record represents one potential deal: a specific chance to sell something to a specific customer, with an expected value and an expected close date.
Three ideas define the object:
- It is a deal, not a company or a person. The Account is the company, and the Contact is a person at that company. The Opportunity is the sale you are pursuing with them.
- It has a lifecycle. An opportunity is open while the deal is being worked. It ends as Closed Won or Closed Lost.
- It carries forecast data. Amount, Close Date, and Stage feed pipeline reports and forecasts. Most revenue reporting in Sales Cloud comes from this object.
An account can have many opportunities. A new customer may start with one deal. Later you might add a renewal, an expansion, and a separate project, each as its own record. Keeping them separate lets you track win rates, amounts, and timing for each deal on its own.
Where it fits in the data model
Opportunity connects to several other objects. Knowing these links helps you decide where data belongs and why some fields behave the way they do.
| Related object | Relationship to Opportunity | Why it matters |
|---|---|---|
| Account | Many opportunities can belong to one account (lookup). | Gives the deal a customer. Account history shows all past and open deals. |
| Contact | Linked through Opportunity Contact Roles, a many-to-many link. | Records who is involved in the deal and in what role. |
| Lead | A converted lead can create an opportunity. | Passes qualified interest into the pipeline. |
| Campaign | An opportunity can have a primary campaign source. | Supports attribution of revenue to marketing. |
| Product and Price Book | Linked through Opportunity Products (line items). | Builds the Amount from priced products. |
| Quote and Order | Can be created from an opportunity. | Supports the later steps of selling. |
| User | The opportunity has an Owner, and can have an opportunity team. | Decides who works the deal, who sees it, and whose forecast it counts toward. |
The Account relationship is a lookup, not a master-detail. That choice matters for two reasons. First, an opportunity has its own owner and its own sharing, rather than inheriting from the account. Second, deleting an account does not simply remove the data without checks. Salesforce restricts deletion of accounts that have certain related records, such as closed won opportunities, unless that behavior has been changed by an administrator.
A standard opportunity does not require an account in every configuration, but nearly all real sales processes attach one. Orgs that use person accounts, or that allow private opportunities with no account, are a variation you may meet in some orgs.
The opportunity lifecycle
Every opportunity moves through stages. A stage is a step in your sales process, held in the Stage picklist. The first picklist value is typically an early step such as Prospecting. The last values are the closed ones.
Some points about the lifecycle:
- Creation. A rep creates the opportunity by hand, or it is created when a lead is converted. Automation and integrations can also create them.
- Open stages. The deal moves forward as the rep qualifies the customer, presents a proposal, and negotiates. Stages can be skipped or revisited unless you add rules that prevent it.
- Closed stages. Closed Won means the deal was won. Closed Lost means it was lost. Each closed stage is flagged as such, which sets the IsClosed and IsWon values on the record.
- Reopening. A closed opportunity can be moved back to an open stage if your permissions and rules allow it. Reopening affects reports, so many teams restrict it.
> Note that Salesforce stores these flags on the record. Reports and queries use them, so you never need to compare stage names to find closed deals.
Standard behavior you get for free
Several behaviors come with the object before any configuration.
- Required fields. Name, Close Date, and Stage are required on a standard opportunity.
- Closed flags. IsClosed and IsWon are set from the stage you choose.
- Forecast values. Each stage provides a default probability and forecast category, which the next chapters explain.
- Field history. Salesforce keeps an OpportunityHistory record when Stage, Amount, or Close Date changes. That record is what powers stage history views and reports.
- Reports and dashboards. Standard report types, such as Opportunities and Opportunity History, are available straight away.
Looking at opportunities with SOQL
SOQL is the Salesforce Object Query Language. You can run it in the Developer Console or in a tool such as Salesforce Inspector to see what the data looks like. The query below counts open opportunities and totals their amount for each stage. It is the basic shape of a pipeline report.
SELECT StageName, COUNT(Id) deals, SUM(Amount) total
FROM Opportunity
WHERE IsClosed = false
GROUP BY StageNameThree details are worth noticing:
IsClosed = falseselects every open stage without listing them. If you add a new open stage later, the query still works.StageNameis the API name of the Stage field, even though users see the label Stage.- Aggregate columns need an alias, such as
dealsandtotal, if you want to read them by name in results.
To look at the changes made to one deal over time, query the history object instead. Replace the placeholder with a real record ID.
SELECT StageName, Amount, CloseDate, CreatedDate
FROM OpportunityHistory
WHERE OpportunityId = '006XXXXXXXXXXXXXXX'
ORDER BY CreatedDateEach row is a snapshot saved when one of the tracked fields changed. Reading the rows in order shows the path the deal took.
Where the opportunity sits in the sales workflow
In a typical Sales Cloud setup, the opportunity is the point where interest becomes a measurable deal.
- A lead shows interest. It is qualified by a rep or by automation.
- Lead conversion creates an account, a contact, and optionally an opportunity.
- The opportunity is worked through stages. Reps add contacts, products, and notes.
- The deal closes. A won deal can lead to a quote, an order, or a contract. A lost deal stays in the data, so you can analyze why it was lost.
Leads are for unqualified interest. Once a lead is real enough to have an expected amount and close date, it belongs in an opportunity. Keeping the two apart keeps pipeline reports clean, because only opportunities count toward them.
Common errors and misunderstandings
- Using one opportunity for several deals. If a customer buys three unrelated things, track them separately. Combining them hides win rates and distorts the forecast.
- Creating an opportunity too early. If every inquiry becomes an opportunity, the pipeline is inflated. Use leads for early interest.
- Treating Stage as the only status. Stage tells you where a deal is in the process. It does not tell you its health. Fields such as Next Step and Close Date show what is expected to happen.
- Letting Close Date go stale. An open opportunity with a past close date makes forecast reports unreliable. Many teams add a validation rule or a list view to find these.
- Expecting a stage rule without configuration. Out of the box, reps can jump to any stage. Rules that require a field at a stage come from validation rules, covered in a later chapter.
- Editing history to fix mistakes. History rows cannot be edited. If a stage was set by mistake, fix the current value and accept that the history shows both changes.
Putting it together
Consider a company that sells software subscriptions.
- Account: Northwind Traders.
- Opportunity: "Northwind - 200 seat annual license", Close Date at the end of the quarter, Amount 48,000, Stage Proposal.
- Contact roles: the IT director as Decision Maker, the procurement lead as Influencer.
- Products: a subscription line item with quantity 200.
Northwind later asks for a training package. Create a second opportunity, "Northwind - training," instead of changing the first one. When the first deal closes, its record stays complete, and the training deal has its own stages, amount, and history.
Exercise
A customer account has one open opportunity for a software license. The customer also asks for a separate consulting project. Should you add the consulting work to the existing opportunity or create a new opportunity? Give two reasons.
Show answer
Create a new opportunity. First, the two deals can have different amounts, close dates, and stages, so tracking them together would make forecasts inaccurate. Second, win and loss reporting and stage history are kept per opportunity, so separate records show how each type of deal performs. Products on one opportunity are fine when they are sold together as one deal, but not for unrelated deals.
Exercise
Write a SOQL query that returns the Name and Amount of all opportunities that are closed and won, newest close date first.
Show answer
SELECT Name, Amount FROM Opportunity WHERE IsWon = true ORDER BY CloseDate DESC. IsWon is true only for closed stages marked as won, so you do not need to list stage names.