Tracking Closed Lost Reason Codes on Opportunities in Salesforce

Most businesses want to track and report the reason codes for lost opportunities and ensure that these codes are captured when opportunities are moved to Closed Lost.

In the case of Salesforce CRM, this functionality isn’t available out-of-the-box — however, it can be quickly configured. Fortunately, it’s a simple point-and-click setup, with the steps outlined below.

As a result, when a user — such as a sales representative — closes an opportunity, a reason code must be provided, as shown in the image below:

A screenshot of Salesforce opportunity moving to 'Closed Lost' with 'Reason Lost' code required.
Salesforce CRM – Entering Closed Lost Reason Code

Step 1: Create a “Reason Lost” Field on Opportunity

The first step is to create a list of reason codes:

  1. Go to Setup → Object Manager → Opportunity.
  2. Select Fields & Relationships.
  3. Click New.
  4. Create a Picklist field named Reason Lost. It’s important to use a picklist rather than a text field, as field dependencies do not work with text fields.
  5. Enter your list of reason code values.

Step 2: Add Field Dependencies

Once the Reason Lost field has been created, add a dependency between Stage and Reason Lost:

  1. Go to Setup → Object Manager → Opportunity.
  2. Select Fields & Relationships.
  3. Click Field Dependencies.
  4. Create a new field dependency where Controlling Field is set to Stage and Dependent Field is set to Reason Lost. Include all Reason Lost values:

    A screenshot of a Salesforce field dependency setting ensuring that 'Reason Lost' must be entered on a 'Closed Lost' opportunity.

Step 3: Add a Validation Rule

The final step is to add a validation rule to ensure that a Reason Lost value is required:

  1. Go to Setup → Object Manager → Opportunity.
  2. Select Validation Rules.
  3. Create a validation rule as follows:

    A screenshot of a Salesforce validation rule ensuring that 'Reason Lost' is always selected on a 'Closed Won' opportunity.

Conclusions

At Nexteris, we provide Salesforce development and advanced consulting services, including developing triggers and APEX for complex, high-volume data processing on Salesforce.

Contact us today to find out how we can help you!