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
thuskerthusker 

Need Help with Validation Rule - Return Error Based on Probability %

Hi . . . could use some help on creating a formula (I suck at them).  Management wants to open up the Probability % field to be editable . . . so reps can override the amount that is set by default through Stage selection.  I think it's a bad idea, but if they insist I want to be able to restrict users to only being able to enter the % values we already have.  How would I create a validation rule that would allow users to enter 0,10,50,70,80 90 or 100% but not allow them to save the record with anything else?  I want to keep them from entering 39% and garbage like that.
 
Thanks in advance!
 
 
Jeff TalbotJeff Talbot
NOT(OR(
Probability=0,
Probability=0.1,
Probability=0.5,
Probability=0.7,
Probability=0.8,
Probability=0.9,
Probability=1
))
thuskerthusker
PERFECT . . . thank you so much for the help!  That's exactly what I needed.
thuskerthusker

I tested this in a developes org and it works great.  Ran into a problem in production where a couple users reported getting the error when they had a correct % entered (these are people who actually cannot edt the field anyway--it defaults based on the stage they pick).  So not sure why that would happen but will have to look into it.  Wonder if maybe they had the record open when I activated the rule and there was some kind of "hiccup" that generated the error.  Doesn't make sense that a correct value from the ones listed in the rule would trigger the error.

Anyway . . . thank you again for the help!  This will be great if I can get it to work without any issues. 

Jeff TalbotJeff Talbot
For users that don't have access to the Probability field, it appears that a value isn't written in this field until after the Opportunity record is saved. Therefore, the error showed up because the validation formula doesn't allow for a null value.
 
I recreated your issue while logged in as a user with no access to the Probability field, and the revised formula below solved the problem. Then with the same fix in place I tested wether a user that DOES have access could save an Opportunity with a blank Probability field. I was actually expecting another problem here, but instead found that even though there is nowhere in SF that says Probability is a required field, you can not save an Opporunity record with a blank Probability field if you do have access to the Probability field. Nevertheless, I would highly recommend confirming this with your own testing.
 
NOT(OR(
ISNULL(Probability),
Probability=0,
Probability=0.1,
Probability=0.5,
Probability=0.7,
Probability=0.8,
Probability=0.9,
Probability=1
))
thuskerthusker
Very nice . . . thanks again.  You have bailed me out big time with those 2 formulas.  Very, very, very much appreciated!!!!!  Tough to take advantage of some of the cool things SFDC can do when you don't have the background.  It's so great to have helful people on this forum who can help with this kind of thing!
 
I'll do some additional testing on this.