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
Ajinkya Kulkarni 14Ajinkya Kulkarni 14 

Validation Rule to create Opportunities

I'm creating VR on opportunities with conditions as below but getting error, please suggest the one VR to include all below conditions  :

Opportunities with field Type = Advance Stock field Stock Approval = (“Stock/POS (Standard)” OR “Stock/POS (Discounted)”)

Opportunities with field Type = Consignment Stock, field Stock Approval = (“Consignment & Demo”)

Opportunities with field Type = POS field Stock Approval = (“Stock/POS (Standard)” OR “Stock/POS (Discounted)”)
AnkaiahAnkaiah (Salesforce Developers) 
Hi Ajinkya,

when the validation rule should fire?

Thanks!!

 
Ajinkya Kulkarni 14Ajinkya Kulkarni 14
Hi Ankaiah,

Thank you for your reply, Actually each of these conditions fire seperate validation message.
AnkaiahAnkaiah (Salesforce Developers) 
AND(OR(ISPICKVAL(Type,"Advance Stock"),ISPICKVAL(Type,"POS")), 
OR(NOT(ISPICKVAL(Stock_Approval__c"Stock/POS (Standard)")),
NOT(ISPICKVAL(Stock_Approval__c,"Stock/POS (Discounted)"))))
AND(ISPICKVAL(Type,"Consignment Stock"), 
NOT(ISPICKVAL(Stock_Approval__c"Consignment & Demo")))

try with above two validation rulles.

If this helps, Please mark it as best answer.

Thanks!!

 
Ajinkya Kulkarni 14Ajinkya Kulkarni 14
Hi Ankaiah,
I'm currently trying with below approach but validation error is not executed on Opportunities record as VR is also on Opportunities.
P.S. Stock Approval is multiselect field so using INCLUDES in below formula.

AND(OR(ISPICKVAL(Type,"Advance Stock"), 
OR(INCLUDES( Account.l2a_Stock_Approval__c , "Stock/POS (Standard)")),
INCLUDES( Account.l2a_Stock_Approval__c , "Stock/POS (Discounted)"))))

***Validation Error Message***

AND(OR(ISPICKVAL(Type,"POS"), 
OR(INCLUDES( Account.l2a_Stock_Approval__c , “Stock/POS (Standard)”)),
INCLUDES( Account.l2a_Stock_Approval__c , "Stock/POS (Discounted)"))))

***Validation Error Message***

AND(ISPICKVAL(Type,"Consignment Stock"), NOT(INCLUDES(Account.l2a_Stock_Approval__c, "Consignment & Demo")))

***Validation Error Message***
SteveMo__cSteveMo__c
Personally I find there is little if any value to be gained by combining multiple Validation Rules into a single One-Size Fits All Formula