Loading

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

Date de publication: Apr 3, 2026
Description

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

Résolution

Note:  This solution involves creating a Roll-Up Summary Field and two Validation Rules (one on Opportunity and one on Opportunity Product).

 

Business Case:

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.

 

To prevent create & edit to Opportunity Line Items on Closed Opportunities


Create a Validation Rule on Opportunity Product

  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

 

To prevent deletes to Opportunity Line Items on Closed Opportunities

 

Create a Validation Rule on Opportunity

 

Assumes that you have a custom Roll-Up Summary Field on Opportunity object called Number of Line Items, that Counts the number of Opportunity Product records associated to 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

 

 

 

Ressources supplémentaires

For Additional Validation Rule Samples search the Help & Training for

"Validation Rules: Useful Samples to Get You Started"


Define Validation Rules

Define Roll-Up Summaries

Numéro d’article de la base de connaissances

000385411

 
Chargement
Salesforce Help | Article