function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
XiidaenXiidaen 

Validation Question: Prevent Editing based on role and opportunity stage

I would like to prevent standard users from editing 'Closed/Won' opportunities, based on either forecast category or the specific stage we use.
 
this way, once an opportunity is closed, only an admin or other role we specify can edit that opportunity. 
 
Does anyone know if this is possible, and how to do it?
 
Thanks,
 
Michael
flescorflescor
Have a look at the part of the Help documentation on data validation.  There are a bunch of sample formulas there, and one of them covers this scenario.
XiidaenXiidaen
Thanks for the reply and the advice.  Whe I review that it appears to discuss validating specific fields from being changed...and my issue to to prevent ANY editing at all.  It may be further complicated by the fact that we use revenue schedules.
 
So I guess I'm asking is it possible to make an opportunity Read Only for standard users, based on the stage of the opportunity?
AngieAngie

I've also been working to resolve this same issue.  I do not want my Account Management Team to edit their Opportunities after they have been moved to Closed Won.  I do want to allow the Revenue Team and the System Admin's to have the ability.  I can easily make it so no one can save the record but, I have yet to figure out how to allow the System Admin's or Revenue Team edit the records.  Here is my latest formula, what is wrong with it?

NOT( AND( ISCHANGED( StageName ) , ISPICKVAL( StageName , "Closed Won"), $Profile.Name <> "System Administrator",$Profile.Name <> "FFI Revenue Team"))

gigglesgiggles
Hi Angie,
 
Did you ever get your code to work, i'm trying to do the same thing and having no luck.  With your code it doesn't allow me to save any opportunities  even if the stage name isn't "Closed Won"
AngieAngie
Bad news!  I received an email from Salesforce yesterday saying that it can't be done.  Now I question why they include $Profile if it can't be used for verification on a validation rule in this manor.  Our Customer Success Manager suggested I create a Close Opportunity Record Type using Field Update to change the Record Type to Closed and then restricting the field access by profile.  I'm investigating that avenue now.  Best of luck:smileywink:
CDawsonCDawson
Hi Michael,

This is definitly doable with record types and workflow field updates. Basically you will need to assign a "closed" record type for your opportunity and using a workflow rule with your specific criteria, a field update action will change the record type.

A new page layout will need to be created with all desired fields being marked read-only, this specific page layout will need to be assigned to all user profiles that should not have edit permissions at this stage or better yet the newly created record-type.

To your last comment though, not sure if products/revenue schedules can also be locked due to the limitation in cross-object functionality.(i.e. workflow rules can affect related objects).

Look into record types, workflow rules and page layouts assigned to specifc record types. Let me know if you have any questions. We have implemented simliar rules in a custom object to prevent users from editing the record while certain criteria is met.

Thanks
Chris


Greg PalleschiGreg Palleschi
I have been working towards a resolution for the same problem with no success.

If anyone has a working solution to this problem I would love to know.
AngieAngie
GOOD NEWS!!!  I have a solution from Saleforce and it works:smileyvery-happy:
 
Here is the magic for everyone to use.
 

In order to best protect Closed Won Opportunities, you'll want to have a field that will change when the Opportunity reaches the specific stage and make that field hidden from all but two profiles. Then, you can setup a validation rule based on that field.

Step 1: Create a new Opportunity checkbox field. During the creation of this field, only allow read/write access to FFI Revenue Team and System Administrator profiles. The default value should be unchecked. I named the field "Closed/Won Validation" in my tests which is referred to in the validation rule and field update.

Step 2: Create a Workflow Rule and field update. Your Workflow Rule criteria should be as follows:

Opportunity Stage | equals | Closed Won

And you field update will update your new Opportunity Checkbox field with a check.

Step 3: Create a validation rule with the following formula:

AND(

Closed_Won_Validation__c ,

IF( $User.ProfileId="00e00000006okRY", False, IF( $User.ProfileId ="00e30000000i1iz", False, True))

)

Please note: Once everything is setup, this will only affect Opportunities edited after the Validation and Workflow rules are activated; however, there is a free AppEx application created by Salesforce Labs called "Mass Record Updater 1.2" that will allow you to update the new checkbox field on all Closed Won Opportunities with a check. You can find the application here:

https://www.salesforce.com/appexchange/detail_overview.jsp?NavCode__c=&id=a03300000033a7AAAQ

Have fun!

LindsayJLindsayJ
I tried the Record type and page layout method.  I am doing this for our PRM to ensure that once we take ownership of an opportunity, the reseller cannot edit it (or any history for tha tmatter).  On the new page layout however I cannot make the opp name, date read only.  LIkewise if I take away the button to Edit the page - when I look at the record in the PRM, I can still select Edit and edit key values.
 
Has anyone got this method to work?