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
Felipe FernandesFelipe Fernandes 

Opportunity Validation Rule

Hello.

I have to lock opportunities for any editing (except by administrador) when the stage is Closed Won or Closed Lost, but this rule will prevail only 3 days after the close date.
Example: If the stage is Closed Won or Closed Lost and the Close Date is 10/10, everyone can edit the opportunity until 13/10. After this date only the administrator can edit the opportunity.

I have a code but the 3 days part don't work yet.

 

AND(OR(ISPICKVAL(PRIORVALUE(StageName), "Closed Won"), ISPICKVAL(PRIORVALUE(StageName), "Closed Lost")), NOT( $User.Id = "00580000002yttt"))

 

 

thanks!

 

SporterSporter

 

(
ISPICKVAL(PRIORVALUE(StageName), "Closed Won")
||
ISPICKVAL(PRIORVALUE(StageName), "Closed Lost") )
&& 
NOT( $User.ProfileId = "00580000002yttt" )
&&
(TODAY() -  CloseDate >3)

Try the above and let me know

 

Felipe FernandesFelipe Fernandes

The code works but not completely because I can change the Close date and edit other fields.

SporterSporter

Hmmm ok, haven't tested this fully but have a go with this: (you need to change the system admin id)

 

 

(( 
ISPICKVAL(PRIORVALUE(StageName), "Closed Won") 
|| 
ISPICKVAL(PRIORVALUE(StageName), "Closed Lost") ) 
&& 
(TODAY() - CloseDate >3)) 
&& 
(PRIORVALUE( LastModifiedDate ) <> NOW()) 
&& 
NOT( $User.ProfileId = "00e20000001Nlj" )

 

 

 

 

Felipe FernandesFelipe Fernandes

I can change the Close date and edit other fields whith this code too =/

Thanks a lot fo the help!

skodisanaskodisana

Hi,

Create a custom date field like Custom_Close_Date__c which stores the Close Date at the time of creation. (Use the workflow to populate only at the time of creation).

And write the folllowing validation rule instead of Close Date and the Custom_Close_Date__c field.

 

(
ISPICKVAL(PRIORVALUE(StageName), "Closed Won")
||
ISPICKVAL(PRIORVALUE(StageName), "Closed Lost") )
&&
NOT( $User.ProfileId = "00580000002yttt" )
&&
(TODAY() -  Custom_CloseDate__c >3)

 

 

Thanks,

Kodisana