validation rule is not stopping my users from creating closed won opportunities - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Kerri CartierKerri Cartier 

validation rule is not stopping my users from creating closed won opportunities

I need to stop my sales team from creating opportunites as Closed won, as well as updating them to closed won once created. 

This is the rule I have but its not working 
AND (
ISNEW(),
TEXT(StageName) = "Closed Won",
RecordTypeId ="01241000001AXqTAAW",
$Profile.Name <> "LMN System Admin"
)


This is the rule I have for Edit
ISCHANGED( StageName ) = true

&&

(

TEXT(StageName) = "Closed Won"
)

&&


(($Profile.Name= "Sales- BDR")
||
( $Profile.Name= "Sales-AE User")
||
( $Profile.Name= "Director- SR CSM Standard Profile")
||
( $Profile.Name= "Senior CSM Standard Profile")
||
($Profile.Name= "CSM Standard Profile") )
 
Best Answer chosen by Kerri Cartier
Eric PraudEric Praud
Hi Kerri,

validation rules take 15 digit IDs, not 18.
Also, it's better to use RecordType.Name, it's easier to read, and easier to deploy

All Answers

Eric PraudEric Praud
Hi Kerri,

validation rules take 15 digit IDs, not 18.
Also, it's better to use RecordType.Name, it's easier to read, and easier to deploy
This was selected as the best answer
Steve MolisSteve Molis
+++ EricP

I'm just gonna leave this here... 

User-added image
Eric PraudEric Praud
I was waiting for this @SteveM ;)
Steve MolisSteve Molis
PS.  Are you trying to do something like this?
 
AND(
RecordType.Name = "Your Name Here",
$Profile.Name <> "LMN System Admin"
OR(
AND(
ISNEW(),
TEXT(StageName) = "Closed Won"
),
AND(
ISCHANGED(StageName),
(CASE( StageName , 
"Prospecting",1, 
"Qualification",2, 
"Needs Analysis",3, 
"Value Proposition",4, 
"Id. Decision Makers",5, 
"Perception Analysis",6, 
"Proposal/Price Quote",7, 
"Negotiation/Review",8, 
"Closed Won",9, 
"Closed Lost",9,0) 
- 
CASE(PRIORVALUE(StageName) , 
"Prospecting",1, 
"Qualification",2, 
"Needs Analysis",3, 
"Value Proposition",4, 
"Id. Decision Makers",5, 
"Perception Analysis",6, 
"Proposal/Price Quote",7, 
"Negotiation/Review",8, 
"Closed Won",9, 
"Closed Lost",9,
0)
) > 1
)
)
)

 
Steve MolisSteve Molis
Personally I would split this into 2 separate Validation Rules. 

One for new Opportunities 
AND(
RecordType.Name = "Your Name Here",
$Profile.Name <> "LMN System Admin"
ISNEW(),
TEXT(StageName) = "Closed Won"
)
and another for saved Opportunities
 
AND(
RecordType.Name = "Your Name Here",
$Profile.Name <> "LMN System Admin"
ISCHANGED(StageName),
(CASE( StageName , 
"Prospecting",1, 
"Qualification",2, 
"Needs Analysis",3, 
"Value Proposition",4, 
"Id. Decision Makers",5, 
"Perception Analysis",6, 
"Proposal/Price Quote",7, 
"Negotiation/Review",8, 
"Closed Won",9, 
"Closed Lost",9,0) 
- 
CASE(PRIORVALUE(StageName) , 
"Prospecting",1, 
"Qualification",2, 
"Needs Analysis",3, 
"Value Proposition",4, 
"Id. Decision Makers",5, 
"Perception Analysis",6, 
"Proposal/Price Quote",7, 
"Negotiation/Review",8, 
"Closed Won",9, 
"Closed Lost",9,
0)
) > 1
)

 
Kerri CartierKerri Cartier
I have them as 2 rules now, and yes updated to the Record.Type.Name.  (Facepalm)

Secondly that second part is going to work way better for what I need
Brilliant!