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
gdkgdk 

How to Lock all Opportunities Fields

Hi
     How to lock all Opportuniies Fields immediately upon close (either closed won or closed lost) for all users
      except the opportunity owner and the administrator



Thanks in Advance.
Ashish_SFDCAshish_SFDC

Hi , 


The best option to create a validation rule on the Opportunity Object, 

Criteria :   Status = Closed & Current user != Owner || Current User Profile != System Admin  

Throw Error - Once opportunity is closed it can be edited only by Owner or System Admin. 


Here are two approaches to preventing users from editing Closed or Closed Won opportunity records.  The examples below use example profile IDs in the formula syntax.  Note that the IDs used below will vary by organization.

** CLOSED **
The following Validation Rule will only allows users edit closed opportunities if they are assigned to a Profile ID listed (example is System Administrator "00et0000000q111" or Sales VP "00et0000000q222") will be able to edit the Opportunity.
Validation rule syntax:

AND(
PRIORVALUE( IsClosed ) = True,
NOT(OR(
$Profile.Id = "00et0000000q111",
$Profile.Id = "00et0000000q222"))
)


** CLOSED WON **
The following Validation Rule will only allows users edit closed/won opportunities if they are assigned to single profile ID below (example is System Administrator or "00et0000000q111") will be able to edit the Opportunity.

AND(
ISPICKVAL(PRIORVALUE(StageName),"Closed Won"),
NOT($Profile.Id = "00et0000000q111")
)


http://help.salesforce.com/apex/HTViewSolution?id=000005286&language=en_US


Also, See some samples below, 

https://developer.salesforce.com/docs/atlas.en-us.usefulValidationRules.meta/usefulValidationRules/fields_useful_validation_formulas_userroleprofile.htm


Regards,

Ashish

gdkgdk
Thanks Ashish,
                             Could you pls Share how to Test this in My Edition
Ashish_SFDCAshish_SFDC
Hi , 


See the links below for more information on validation rules, 


https://help.salesforce.com/HTViewHelpDoc?id=fields_about_field_validation.htm&language=en_US

https://help.salesforce.com/HTViewSolution?id=000079759&language=en_US

https://help.salesforce.com/HTViewHelpDoc?id=fields_useful_field_validation_formulas.htm

https://help.salesforce.com/HTViewHelpDoc?id=fields_validation_rules_tips.htm&language=en_US


Regards,
Ashish