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
Paula Jarvis 4Paula Jarvis 4 

Opportunity Validation Rule Not Working as Expected

I have this VR and I only want these Profiles to be able to set the Opportunity Stage = Closed/Won however other Users can still set the Stage = Closed/Won.

Opportunity Validation Rule ~ Salesforce - Enterprise EditionAND(
$Profile.Name ="Custom Sales VP",
$Profile.Name ="Custom Sales Operations",
$Profile.Name="Custom Billing Administrator",
$Profile.Name="System Administrator",
$Profile.Name ="Custom Finance Data Loader",
ISCHANGED(StageName),
TEXT(StageName) = "Closed Won"
)
Best Answer chosen by Paula Jarvis 4
Mahesh DMahesh D
Did you use something like below:

ispickval(StageName, 'Closed Won')

Because it takes 2 parameters, one is field and second one is picklist value.

Regards,
Mahesh

All Answers

Mahesh DMahesh D
Hi Paula,

StageName is a picklist field and you have to use ispickval(StageName, 'Closed Won') function to check the value.

Regards,
Mahesh
Paula Jarvis 4Paula Jarvis 4
I tried using the ISPICKVAL in the RUle above and I get the error message = Opportunity Validation Rule ~ Salesforce - Enterprise EditionError: Incorrect number of parameters for function 'ISPICKVAL()'. Expected 2, received 1
Mahesh DMahesh D
Did you use something like below:

ispickval(StageName, 'Closed Won')

Because it takes 2 parameters, one is field and second one is picklist value.

Regards,
Mahesh
This was selected as the best answer
Paula Jarvis 4Paula Jarvis 4
Mahesh, My Stage name is actually = Closed/Won. It has a hash in it. Could that be the problrm?
Paula Jarvis 4Paula Jarvis 4
Original VR -

Opportunity Validation Rule ~ Salesforce - Enterprise EditionAND(
$Profile.Name ="Custom Sales VP",
$Profile.Name ="Custom Sales Operations",
$Profile.Name="Custom Billing Administrator",
$Profile.Name="System Administrator",
$Profile.Name ="Custom Finance Data Loader",
ISCHANGED(StageName),
TEXT(StageName) = "Closed/Won"
)
Mahesh DMahesh D
Please check below example:

AND(
OR(ISPICKVAL(StageName,"Proposed / Evaluating"),
ISPICKVAL(StageName,"Qualified"),
ISPICKVAL(StageName,"Negotiating"),
ISPICKVAL(StageName,"Accepted"),
ISPICKVAL(StageName,"Closed Won"),
ISPICKVAL(StageName,"Closed Lost"),
ISPICKVAL(StageName,"Closed - No Opportunity")))

User-added image
Regards,
Mahesh
Parker EdelmannParker Edelmann
Your original validation rule is set so that a user would have to be all the above profiles. Try something like this: 
AND( !OR(
$Profile.Name ="Custom Sales VP",
$Profile.Name ="Custom Sales Operations",
$Profile.Name="Custom Billing Administrator",
$Profile.Name="System Administrator",
$Profile.Name ="Custom Finance Data Loader"),
ISCHANGED(StageName),
ISPICKVAL(StageName, "Closed Won")
The formula works like this If the user is not ( the "!" works as the NOT() Function does) one of the mentioned profiles, and the Stage was changed to the value of Closed Won, the rule fires. Hope this does the trick for you, 

Parker