+ Start a Discussion
Mohan Raj 33Mohan Raj 33 

validation rule is not working. Why ?

IF( ISPICKVAL( StageName , "Closed Won") ||  ISPICKVAL( StageName,  "Closed Lost" )  ,    PRIORVALUE( StageName )  , PRIORVALUE( NOT ( StageName ) )  )

here I want the validation rule for when I select the Opportunity itself on the "stage" piclist value is selected in any one of "Closed Won " or "Closed Lost" then the value of the particular opportunity is not changed(that stage field in the "Closed Won" to Other(Closed Lost also) or "Closed Lost" to Other(Closed Won also) ) before. Here I tried as well as I know in the validation rule for the task but It's gives the error by followingly, "Error: Field StageName is a picklist field. Picklist fields are only supported in certain functions.".So please help me to complete ths task.For answers thanks in advance. 
Best Answer chosen by Mohan Raj 33
karthikeyan perumalkarthikeyan perumal
Hello Mohan, 

Use below update code, 
 
AND( 
OR(AND(ISCHANGED(StageName), 
ISPICKVAL(PRIORVALUE(StageName),"Closed Won")) 
, 
AND(ISCHANGED(StageName), 
ISPICKVAL(PRIORVALUE(StageName),"Closed Lost")) 

))
Hope this will help you.
Mark it solved if works for you.

Thanks
karthik
 

All Answers

Rakesh ARakesh A
Mohan, you have used pick list values like ' ISPICKVAL( StageName, "Closed Lost" ) ' which is correct, but in last two statements you have used 'PRIORVALUE( StageName )' and it should not be. Picklist(StageName ) values always should have funciton  ' ISPICKVAL( StageName, "Closed Lost" ) ' .

And clearly explain your task , so that I will help you to solve it
Mohan Raj 33Mohan Raj 33
@Rakesh A 3, Thank you For reply . Here I Want once If I  selected the stage piclist field  in the Opportunity is "Closed Won " or "Closed Lost" means then it's not changeble to another including this both(like closed won to closed lost and vice versa also ).Thank you Mohan 
Mohan Raj 33Mohan Raj 33
@ karthikeyan perumal Thanks for reply. Sorry sir Here I want If selected Once the stage piclist value to the "Closed won " or "Closed Lost " after it's not changeble to any other values in the stage piclist values it's my task requirement. So your Code is not fulfill the requirement for my task.
Mohan Raj 33Mohan Raj 33
@Karthikeyan Perumal, Thanks for the reply now also you're code doesn't help me because I want once I selected the "Closed Won" or "Closed Lost' it doesn't changeble in the next time where I tried to change in the edit mode with not also in closed won to closed lost and vice versa also. Now also you not understanding clearly see below.
if (stage == "closed Won" or "closed Lost"){
it's not changed any other in the stage field piclist options (including the closed won to closed lost also not possible in this condition) 
else(other all valuesin the stage field are chenges to another one in the list of piclist (Note:here also if changed the another value into closed won or closed lost after it's not changeble));}
Mohan Raj 33Mohan Raj 33
@Rakesh A 3 if you still confussion on my task deteails below the requirements:
I want the opportunity stage is in never changeble once it's to be set the value of "closed Won" and "Closed Lost ".
Then the Other all stage items are changeble to one to another(as normal).
If I selected to the other one to closed won or closed lost it's also maintain on the constant  after it's set to be a "closed won" or "closed lost".
If I try to change the stage value "closed won" or "closd lost" to another it's provide a error message.I think now you are clear undertand my task I hope.Thank you, Mohan 
 
Mohan Raj 33Mohan Raj 33
@karthikeyan perumal if you still confussion on my task deteails below the requirements:
I want the opportunity stage is in never changeble once it's to be set the value of "closed Won" and "Closed Lost ".
Then the Other all stage items are changeble to one to another(as normal).
If I selected to the other one to closed won or closed lost it's also maintain on the constant  after it's set to be a "closed won" or "closed lost".
If I try to change the stage value "closed won" or "closd lost" to another it's provide a error message.I think now you are clear undertand my task I hope.Thank you, Mohan 
 
karthikeyan perumalkarthikeyan perumal
Hello Mohan

Try this 
 
AND( 
OR( 
ISPICKVAL(PRIORVALUE(StageName),"Closed Won"), 
ISPICKVAL(PRIORVALUE(StageName),"Closed Lost") 

))

if its failing let me know which condition its failing, 

its works makr it solved.. 

Thanks
karthik
 
Mohan Raj 33Mohan Raj 33
@karthikeyan Perumal Thanks for the reply. Your very near to the correct code of my task but It's has small mistake in your sending code what is it means if once I set the value of the stage piclist to the "closed won" or "closed lost" it's saved and I try to change this value to another it produce the error result it's okay.
BUT IN HERE WHAT IS THE PROBLEM MEANS once I try to change the "closed won" stage to same closed won stage it's also produce the error(It's also same as in the "closed Lost" case once I try to change the value to "closed lost" to again "closed lost" it's also provide the error).so please try to rectify this error only.
It's a problem in this code instand of this it produce all the output correctly.Thank you, Mohan
karthikeyan perumalkarthikeyan perumal
Hello Mohan, 

Use below update code, 
 
AND( 
OR(AND(ISCHANGED(StageName), 
ISPICKVAL(PRIORVALUE(StageName),"Closed Won")) 
, 
AND(ISCHANGED(StageName), 
ISPICKVAL(PRIORVALUE(StageName),"Closed Lost")) 

))
Hope this will help you.
Mark it solved if works for you.

Thanks
karthik
 
This was selected as the best answer
Mohan Raj 33Mohan Raj 33
@karthikeyan Perumal Thank you very much sir.It's really helpful for me.