Problem: We’re using a “Closed Won” Opportunity as a financial booking and we need a way to lock the record from people editing it once it reaches this state. This also means we can’t allow people to modify the Opportunity LineItems (aka Opportunity Products).
Solution: Validation Rules to the rescue!
I originally searched Google / SFDC Help for validation rules and triggers for delete but didn’t find any articles that made it apparent. A validation rule is executed any time a record is saved either through the Salesforce.com Application or through the API (including Outlook, Excel Connector, and custom code). In our case, Opportunities are only allowed to be deleted by Admin role (me). This means that they can only be edited (1/2 the battle).
This means we need two Validation rules…
- Disallow editing of an Opportunity once the stage is “Closed Won”: and(PRIORVALUE(StageName) = “Closed Won”, not( $UserRole.Name = “Finance”))
- Disallow editing of Opportunity Products once the Opportunity Stage is “Closed Won”: AND( NOT($UserRole.Name = “Finance”), ISPICKVAL( Opportunity.StageName , “Closed Won” ))
Now, when someone (sales, support, whoever) tries to edit the Opportunity to change the date, they will receive the error message from validation rule 1, hopefully stating they need to go to finance to make changes. If someone tries to update an Opportunity Product amount, description, or custom field they will receive an error from validation rule 2. In this example, only Finance can edit your Closed Won Opportunities but you could also unlock it for Admin or other roles depending on the size of your organization.
This was implemented for use in a close process where Salesforce.com is tied out completely to contract values so we can use Lucidera and Salesforce.com reports for real business decisions as we are completely confident the data is correct. What do you think?
jamesrsullivan: No more IM (Skype, Google Talk, Yahoo, MSN, Facebook, Gadu Gadu, ICQ, or AIM) until I am caught up on email...






December 4th, 2008 at 3:20 pm
I’m having some trouble getting this to work. This is the code I’m using:
and(PRIORVALUE(StageName) = “Won-Signed”, not( $UserRole.Name = “TelemarketingM”))
The role name is TelemarketingM, and I want the Opportunity locked once the stage hits Won – Signed. Any help would be greatly appreciated, thanks!
December 7th, 2008 at 10:59 pm
Justin,
The formula you entered above says to trigger when there is an edit and the StageName is already Won-Signed and the person doing the editing is not TelemarketingM…
So, if you’re testing with someone that has the role TelemarketingM they are exempt from the rule. If you want to make it apply to everyone, change it to:
PRIORVALUE(StageName) = “Won-Signed”