+ Start a Discussion
rachel.benson@earley.comrachel.benson@earley.com 

Locked Opportunity Formula

I need to create a formula that locks opportunities once they reach a certain stage. We want only a the administrator to be able to make changes once the opportunity hits the stage so we can make sure the date and the amounts don't change. Can someone help explain how I would go about creating the formula or if this is even possible?

Best Answer chosen by Admin (Salesforce Developers) 
SteveMo__cSteveMo__c

Okay, you might wanna add a VR to the Opportunity Product object just to be safe, something like:

 

AND(
ISCHANGED(TotalPrice),
Opportunity.IsWon = TRUE,
$Profile.Name <> "System Administrator")

 

All Answers

venkat-Dvenkat-D

If it is only couple of fields which you do not want to change after reaching a certain stage, use validation rule.

If you need to lock complete record, then create a Read only page layout and record types.Then use workflow to change record type when opportunity stage is reached and users wont be able to edit the recorrd.

rachel.benson@earley.comrachel.benson@earley.com

From what I know we don't want anything on the opportunity to be changed once it reaches our stage closed won unless done by a system administrator.  In that case we would do the read only page layout?

venkat-Dvenkat-D

Yes, you can create a page layout with all the fields as read only and create a read only record type. Use workflow to update the record type to read only when stage is Closed. 

SteveMo__cSteveMo__c

Which edition of SFDC are you using?

rachel.benson@earley.comrachel.benson@earley.com

enterprise edition

SteveMo__cSteveMo__c

EE!!!   Diggity!!!  You are in the game!!!  

 

Okay there are a few options you have (depending on what your requirements are).  Probably the easiest would be to create a custom Opportunity Record Type and Page Layout called "Closed/Locked" or something like that.  But you can call it "Sack of door knobs" if you want, it's your SFDC org.  Make every field on the Page Layout "Read Only"    Change the Page layout assignment so that all profiles except Admin are set to RecType: Closed/Locked = PageLayout: Closed/Locked

 

Then create a Workflow Rule (WFR) that is evaluated "Every time the record is created or editied" and triggered when IsClosed = TRUE.  

 

Then add a Field Update action that sets the Record Type from "WhatEv..." to "Closed/Locked" or "Sack of door knobs"  

 

Then buy your buddy SteveMo some beer and ship it to him (I like IPA's)

rachel.benson@earley.comrachel.benson@earley.com

Thank you for the help.

 

If I change the page lay out will it affect all current opportunities that were created before I changed the layout? I am very green when it comes to customization like this. I don't want to mess the opportunities we have already. All we want is one field to be locked after the opportunity is closed won and only one type of user to be able to make changes to that locked field if necessary.

SteveMo__cSteveMo__c

Okay if it's just 1 field that needs to be locked you can take care of that with a VR.  I thought you wanted to lock everything or most of the fields.  So which fields do you need to lock and what is the datatype?

rachel.benson@earley.comrachel.benson@earley.com

As did I. At first I was under the impression they wanted to lock all of the fields on the opportunity. We want to lock the amount field for all opportunities that become stage 6-closed won. The administrator should be the only with the ability to change the amount if necessary.

SteveMo__cSteveMo__c

Diggity!!!  I have a VR that does just the trick....  lemme dig it up.

SteveMo__cSteveMo__c

Okay here's one you can borrowand hack around. 

AND(
OR(
IsWon = TRUE,
PRIORVALUE(IsWon) = TRUE), 
ISCHANGED(Amount),
$Profile.Name <> "System Administrator")

 PS.  You owe me a beer!  ;-D

SteveMo__cSteveMo__c

Hi Rachel are you all set or do you still need help with this?

rachel.benson@earley.comrachel.benson@earley.com

I added the VR did I also need to create  a wfr so that the lock field rule took affect?

SteveMo__cSteveMo__c

No the WFR was just if you wanted to create a completely locked down Page Layout and Record Type, but since you only need to lock 1 field the VR should take care of it.  One thing though, are you guys using Products?  If you are you might want to add another VR to lock them down.

rachel.benson@earley.comrachel.benson@earley.com

We do use product but I don't believe they are selected for all opportunities. It is not a required field.

SteveMo__cSteveMo__c

Okay, you might wanna add a VR to the Opportunity Product object just to be safe, something like:

 

AND(
ISCHANGED(TotalPrice),
Opportunity.IsWon = TRUE,
$Profile.Name <> "System Administrator")

 

This was selected as the best answer
SteveMo__cSteveMo__c

PS.  You SO owe me a beer for this!  ;-p

SteveMo__cSteveMo__c

Rachel, are you all set with this or do you still need help?   And when do I get my beer???

rachel.benson@earley.comrachel.benson@earley.com

Hi Stevemo I believe I am good Thank you so much. I'll have to remember to ship you two cases first class.

gramch88gramch88

How can I lock down a certain field based on another custom field? I want the market segment field on the opportunity to be read only if the sub stage is populated. Only 3 users should have access to change the field. I tried this VR but it didnt work:

AND( 
ISCHANGED( Market_Segment__c ), 
ISPICKVAL(Sub_Stage__c, "Free Trial Active"), 
ISPICKVAL(Sub_Stage__c, "Free Trial Inactive"), 
$User.Id <> "00550000001DCwG", 
$User.Id <> "00550000001kYJh" , 
$User.Id <> "00550000001jalm" 
)

 

Let me know if you can help!