Print this page

How do I lock the Opportunity Products using Validation Rules once the Opportunity Stage is Closed?

Knowledge Article Number 000004872
Description

How do I lock the Opportunity Products using Validation Rules once the Opportunity Stage is Closed?

Resolution

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

 

 

For Additional Validation Rule Samples search the Help & Training for

"Validation Rules: Useful Samples to Get You Started"

 

 





promote demote