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

Expanded Validation rule to apply quantity to product codes - Stuck!

Stuck again!


I am using the following code to produce an error message when the Quantity for specific product numbers (listed below) is up to 499 users AND when the discount exceeds 40%. What I'd like to do is expand this code to include a number of quantity ranges, say 500-999, 1000-1500 etc, where the discount  (against the same product codes) should not exceed 45%, 50%, 60%, respectively.


Is there a way to do this in one code string rather than create unique validation rules? Here's what I am works  for up to 499 users, and up to 40% discount:


(Product2.ProductCode= "EN-P-MPS-100",
Product2.ProductCode= "EN-P-PC-100",Product2.ProductCode= "EN-P-CP-100",Product2.ProductCode= "EN-P-IP-100",Product2.ProductCode= "EN-P-AW-100",Product2.ProductCode= "EN-P-AWS-100",Product2.ProductCode= "EN-P-CCE-110",Product2.ProductCode= "EN-P-OC-100",Product2.ProductCode= "GE-P-MPS-100",Product2.ProductCode= "GE-P-PC-100",Product2.ProductCode= "GE-P-OC-100",Product2.ProductCode= "EN-P-ICM-200",Product2.ProductCode= "EN-P-SPPM-200",Product2.ProductCode= "EN-P-MISCA-300",Product2.ProductCode= "EN-P-MIBCA-310",Product2.ProductCode= "EN-P-MISCIT-320"),
(Quantity<= 499)),  Discount  > 0.40)


Put another way, how do I introduce quantity ranges, each with a unique discount % against the same product codes in the same validation rule?


Thanks in advance for the help!


Basically a bunch of ANDs within an OR. Try something like:



AND(Quantity<=499, Discount > .4),

AND(Quantity >= 500, Quantity <=999, Discount > .5),

AND(Quantity >= 1000, Quantity <=1499, Discount > .6) )