Loading

Lock the Opportunity Product with validation rules once the Opportunity Stage is closed

Дата публикации: Oct 12, 2026
Описание

How can Opportunity Products be prevented from being edited or modified using Validation Rules once the Opportunity Stage is marked as Closed?

Решение

This article explains how to lock Opportunity Products in Salesforce so users cannot create, edit, or delete them after the Opportunity Stage is set to Closed Won or Closed Lost. This solution involves creating a Roll-Up Summary Field and two Validation Rules (one on Opportunity and one on Opportunity Product).

Business Case for Locking Opportunity Products on Closed Opportunities

A Sales Manager wants to block any changes to Opportunity Line Items for all Closed Opportunities. By adding one Roll-Up Summary Field and two Validation Rules, the Sales Manager can enforce this business policy.

Prevent Create and Edit Actions on Opportunity Line Items on Closed Opportunities

Create a Validation Rule on Opportunity Product with the following settings.

  1. Description: Prevents users from editing opportunity products after an opportunity is closed. Create the following validation rule example on opportunity products.
  2. Formula: OR(ISPICKVAL(Opportunity.StageName, "Closed Won"), ISPICKVAL(Opportunity.StageName, "Closed Lost"))
  3. Error Message: Opportunity Line Items cannot be created or edited because the Opportunity is closed.
  4. Error Location: Top of Page

Prevent Delete Actions on Opportunity Line Items on Closed Opportunities

Create a Validation Rule on Opportunity with the following settings. This solution assumes that you have a custom Roll-Up Summary Field on the Opportunity object called Number of Line Items, which counts the number of Opportunity Product records associated with an Opportunity.

  1. Description: Prevents users from deleting opportunity products after an opportunity is closed. Create the following validation rule example on opportunities. It uses a custom roll-up summary field on opportunities that counts the number of opportunity products on an opportunity.
  2. Formula: AND(OR(ISPICKVAL(StageName, "Closed Won"), ISPICKVAL(StageName, "Closed Lost")), Number_of_Line_Items__c < PRIORVALUE(Number_of_Line_Items__c) )
  3. Error Message: Opportunity Line Items cannot be deleted because the Opportunity is closed.
  4. Error Location: Top of Page
Номер статьи базы знаний

000385411

 
Загрузка
Salesforce Help | Article