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
DeptonDepton 

validation on opportunity, if picklist equals WON and Account name equals ACME get an error message

Hi,

 

I guess this is a simple one.

 

When selecting Stage=WON i would like to get an error message if the Account selected is an specific one: ACME

 

Thank you

Best Answer chosen by Admin (Salesforce Developers) 
DeptonDepton

I like this Stevemo, but I want the opportunity NOT to be saved if the STAGE is WON and the  account is ACME

 

AND(IsWon,Account.Id = "001001001AcMe")  

 

What do I have to change?

All Answers

BaLab2aBaLab2a

Hi,

 

 

((ISPICKVAL(StageName,'Closed Won') )&& IF(Account.Name='ACME',true, false))

 

 

please check whether it works..

 

Thanks,

Bala

Steve :-/Steve :-/

I try to stay away from using Opportunity StageNames when evaluating Open/Closed Won/Lost, etc.  I like to use the SFDC System Fields 'IsClosed' and  'IsWon'  they make writing VR's WFR's na d Formulas a LOT easier, and they don't need to be updated if someone adds a new Stage or Sales Process.

 

 

AND(IsWon, Account.Name = "ACME")

 

 

 

Steve :-/Steve :-/

Also, if the Account Name isn't locked down you might want to refer to something that can't be chaged like the Account.Id or a custom field that is locked/hidden

 

AND(IsWon,Account.Id = "001001001AcMe")  

 

 

Steve :-/Steve :-/

another approach woul be to attack it from the Account side and create a Roll-Up Summary field that counts the number of Opportunties and throws an error if a new one is created.

DeptonDepton

I like this Stevemo, but I want the opportunity NOT to be saved if the STAGE is WON and the  account is ACME

 

AND(IsWon,Account.Id = "001001001AcMe")  

 

What do I have to change?

This was selected as the best answer
Steve :-/Steve :-/

Depton,

Can you clarify what your Opportunity Stages are?  Are you trying to prevent the Opportunity from being Closed/Won if the Account = Acme?  Or are there other Opportunity Stages that are = Closed/Won that are okay for the Acme account and you just want to prevent 1 specific stage?   

 

As I said in my earlier post I avoid using Opportunity.StageName whenever possible because it makes managing VR, WFR, and Formula Fields a nightmare if you have multiple Sales Processes.

DeptonDepton

I am  just trying to prevent the Opportunity from being Closed/Won if the Account = Acme

 

:)

Steve :-/Steve :-/

Then either of the VR's that I posted should work for you

DeptonDepton

Hi Bala,

 

Thank you very much!! this one also worked!!!:))

DeptonDepton

Thank you for the solution and for the class Stevemo!