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
Eric FraserEric Fraser 

ISPICKVAL in conjunction with ISCHANGED

I am trying to make a validation rule to go along with my apporval process.  I need to lock the stagename pick list for 3 of my stages below. The code I have kinda works. I just can not save any opportutiny that is within that stage. 

My question is: how do I make the validation rule where as once the opportunity is in that stage (after apporval) the validation turns off for that stage so I can modify and save that opportunity.

AND(
$Profile.Name <> "System Administrator",
OR(
ISPICKVAL(StageName, "Pursue"),
ISPICKVAL(StageName, "Target"), 
ISPICKVAL(StageName, "Bid")
))
Best Answer chosen by Eric Fraser
venkat-Dvenkat-D
Found reference to another one that should work. Use this.

ISPICKVAL(PRIORVALUE(Request_Status__c),"Error")

https://developer.salesforce.com/forums/?id=906F00000008pFfIAI

 

All Answers

Pankaj_GanwaniPankaj_Ganwani
Hi Eric,

Can you please let us know what will be the value of stagename field once the record is approved? I believe you are using field update on StageName field in approval process.

Thanks,
Pankaj
Eric FraserEric Fraser
Hi Pankaj,

Yes I am using a field update in the approval process.  All opportunities start in "Concept" then when it is approved it is updated to "Pursue" then to "Target" then to "Bid". I want the validation rule to keep my employees from changing(locking stage field) the stage on their own but just for these 3 specific stages. Let met know if you have any other questions.

I really apprecaite your help,
Eric
venkat-Dvenkat-D
Try 
ISCHANGED(StageName ) && PRIORVALUE(StageName)  = "Bid" && ISPICKVAL(StageName, "Target")
Eric FraserEric Fraser
AND(
$Profile.Name <> "System Administrator",
ISCHANGED(StageName), 
PRIORVALUE(StageName) == "Pursue", 
ISPICKVAL(StageName, "Target") 
)

I modified it to what I have and this would just be a snipit of moving from "Pursue" stage to "Target" Stage. But it is not working...
venkat-Dvenkat-D
Found reference to another one that should work. Use this.

ISPICKVAL(PRIORVALUE(Request_Status__c),"Error")

https://developer.salesforce.com/forums/?id=906F00000008pFfIAI

 
This was selected as the best answer
Eric FraserEric Fraser
This one works for only the "Pursue" Stage!

AND(
$Profile.Name <> "System Administrator",
ISPICKVAL(PRIORVALUE(StageName),"Pursue"),
OR(
ISPICKVAL(StageName, "Target"),
ISPICKVAL(StageName, "Bid")
))

Thank you for your help, Ill make other validations for the different stages!
Eric FraserEric Fraser
SOLUTION: I only wanted to control the movement between a few stages. So to control these movements I created a validation for each stage:

Concept stage Validation Rule:
AND( 
$Profile.Name <> "System Administrator",                        //only system admins can modify all stages
ISPICKVAL(PRIORVALUE(StageName),"Concept"),       //prior value in stagename was concept
OR( 
ISPICKVAL(StageName, "Pursue"),                                  //new value in stagename is pursue
ISPICKVAL(StageName, "Target"),                                   //new value in stagename is target
ISPICKVAL(StageName, "Bid")                                         //new value in stagename is bid
))

// If you want to lock all stages then dont use anything after the OR, there are stages that I want the emplyee to be able to change it to such as "No Bid", in our company we do not need approval to No bid.

Pursue stage Validation Rule:
AND( 
$Profile.Name <> "System Administrator", 
ISPICKVAL(PRIORVALUE(StageName),"Pursue"), 
OR( 
ISPICKVAL(StageName, "Target"), 
ISPICKVAL(StageName, "Bid") 
))

Target stage Validation Rule:
AND( 
$Profile.Name <> "System Administrator", 
ISPICKVAL(PRIORVALUE(StageName),"Target"), 
ISPICKVAL(StageName, "Bid") 
)

This was easly done with cloning the orginal Validation Rule

Thank you for your help and hopefully this can help some one else in the future!
Eric
venkat-Dvenkat-D
Eric,
mark the solution that helped to resolved so that it can help others.