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
Sienna Luard 3Sienna Luard 3 

How do you make opportunities read only when there is a field update change

Currently Opportnities are public with Create.Read, Edit & Delete permissions for all users.
We want to keep it that way for oppruntities that are pending or closed lost.

We do want to have Opportunities that are Closed Won to become Read Only for Sales and Marketing. 

The only profle that would be able to edit Closed Won Opportunities would be Accounting users. 

Any ideas?
Best Answer chosen by Sienna Luard 3
jigarshahjigarshah
@Sienna Luard3 There are multiple ways you could accomplish this using out of the box features and would not need custom code.

Approach # 1 - Using Validation Rules 
You could write a simple validation rule on Opportunity that checks for Opportunity.Status = 'Closed Won' and displays an error message thus restricting the User from makign any changes. The rule would be as follows. This is a more reactive approach rather than a proactive one. In case you need the behaviour to be proactive use approach # 2
ISPICKVAL(PRIORVALUE(Opportunity.Status), "Closed Won")

Approach # 2 - Using Workflows and Record Type 
The solution revovles around changing the Page Layout of an Opportunity to a Read Only layout once is is saved with the Status = Closed Won. The approach would be as follows.

1. Create 2 Record Types - Working Opportunity and Won Opportunity.
2. Also create 2 Page Layouts - Working Opportunity Layout and Won Opportunity Layout. Both these layouts would exactly contain the same fields except that the fields on the Won Opportunity Layout would be Read Only.
3. Assign the respective Page Layouts to their respective Record Types created in steps #1 and #2. Ensure that the Working Opportunity is set as the Default Record Type for Opportunity.
4. Create a workflow on Opportunity which fires on the criteria {!Opportunity.Status} = "Closed Won".
5. Add a Workflow field update action to the workflow in #4. The action updates the RecordType field on Opportunity, to the Won Opportunity Layout. When this record type assignment happens the Won Opportunity Layout would automatically be assigned making the Opportunity record Read Only.

Let me know if that helps you resolve the issue.

All Answers

Nithesh NNithesh N
I think Criteria-Based Sharing Rules Will solve it.
Check the links below 
https://help.salesforce.com/articleView?id=security_sharing_cbs_about.htm&type=0
https://help.salesforce.com/articleView?id=security_sharing_rules_create_opp.htm&type=0  (https://help.salesforce.com/articleView?id=security_sharing_rules_create_opp.htm&type=0 )
https://www.youtube.com/watch?v=JTrkKziqh90

Let me know if it helps.

Best,
Nithesh
jigarshahjigarshah
@Sienna Luard3 There are multiple ways you could accomplish this using out of the box features and would not need custom code.

Approach # 1 - Using Validation Rules 
You could write a simple validation rule on Opportunity that checks for Opportunity.Status = 'Closed Won' and displays an error message thus restricting the User from makign any changes. The rule would be as follows. This is a more reactive approach rather than a proactive one. In case you need the behaviour to be proactive use approach # 2
ISPICKVAL(PRIORVALUE(Opportunity.Status), "Closed Won")

Approach # 2 - Using Workflows and Record Type 
The solution revovles around changing the Page Layout of an Opportunity to a Read Only layout once is is saved with the Status = Closed Won. The approach would be as follows.

1. Create 2 Record Types - Working Opportunity and Won Opportunity.
2. Also create 2 Page Layouts - Working Opportunity Layout and Won Opportunity Layout. Both these layouts would exactly contain the same fields except that the fields on the Won Opportunity Layout would be Read Only.
3. Assign the respective Page Layouts to their respective Record Types created in steps #1 and #2. Ensure that the Working Opportunity is set as the Default Record Type for Opportunity.
4. Create a workflow on Opportunity which fires on the criteria {!Opportunity.Status} = "Closed Won".
5. Add a Workflow field update action to the workflow in #4. The action updates the RecordType field on Opportunity, to the Won Opportunity Layout. When this record type assignment happens the Won Opportunity Layout would automatically be assigned making the Opportunity record Read Only.

Let me know if that helps you resolve the issue.
This was selected as the best answer
jigarshahjigarshah
I am sorry I realized later that Approach # 2 may not work since you want specific Profiles to be able to edit Closed Won Opportunity. You could add a specific exlcusion critera in the Validation rule to exclude edit restrictions on Accounting Profile Users. Assuming the name of Profile is set as Accounting the validation rule now becomes.
AND(ISPICKVAL(PRIORVALUE(Opportunity.Status), "Closed Won"), $Profile.Name <> "Accounting")

This should definitely help you fix the issue.
Sienna Luard 3Sienna Luard 3
Thanks so much for all of your help! The validation rule worked like a charm. (-; Regards, Sienna
jigarshahjigarshah
@Sienna Luard - If you think this helped, can you mark this as the best answer and upvote it.
Sienna Luard 3Sienna Luard 3
Thanks jshah, I just liked your answer and flagged it as the best answer. Regards, Sienna
jigarshahjigarshah
@Sienna Luard Thanks a ton.
Rahul AnkireddypalliRahul Ankireddypalli
i have slightly defer to the approach 2 of @jigarsha because we can't make all the fields READ ONLY as the REQUIRED fields cant be made READ-ONLY