0

I have written the below Validation Rule to check two values on an Opportunity record to ensure they equal each other in certain stages. However, during testing, it is confirmed that Users are suffering from being unable to save the record and hitting the error message even though the two values are identical. Can anyone assist? Thank you.

AND 
((Total_Deal_Price__c <> Product_Roll_Up_Total__c), 

OR( 
ISPICKVAL (StageName, "5 - Negotiate"), 
ISPICKVAL (StageName, "6 - Contract"), 
ISPICKVAL (StageName, "7 - Closing"), 
ISPICKVAL (StageName, "Closed Won") 
)) && $User.Bypass_Workflows__c = false && ((RecordType.Name ="Products and Services") || (ISPICKVAL(Order_Sub_Type__c, "Contract Renewal")))
  • Would be helpful to know what the conditions are where the rule is failing. You have 4 stage names you're trying to exclude along with a RecordType, Order_Sub_Type__c, & $User.Bypass_Workflows__c. How do those apply? Perhaps the issue is with the latter three not having an OR? – crmprogdev Jun 16 '16 at 14:00
  • @crmprogdev, thank you for the quick reply. It is failing upon changing the Stage, or even a value on a related record, which is even more odd to me. I agree, the problem is probably not the top Total Deal Price vs. Product Roll Up Total calculation, but rather something else, specifically something after the "OR(". – Tamim J Jun 16 '16 at 14:25
  • 1
    Try to use ROUND: ROUND(Total_Deal_Price__c, 2) != ROUND(Product_Roll_Up_Total__c, 2) – o-lexi Jun 16 '16 at 16:31
1

If you want to use the AND, I believe you want your syntax to look more like this:

AND 
((Total_Deal_Price__c <> Product_Roll_Up_Total__c), 

OR( 
ISPICKVAL (StageName, "5 - Negotiate"), 
ISPICKVAL (StageName, "6 - Contract"), 
ISPICKVAL (StageName, "7 - Closing"), 
ISPICKVAL (StageName, "Closed Won") 
), $User.Bypass_Workflows__c = false, ((RecordType.Name ="Products and Services") 
|| (ISPICKVAL(Order_Sub_Type__c, "Contract Renewal"))))

Tacking on the &&'s at the end of your formula didn't make sense to me.

  • I appreciate you writing that out. Can you detail for me why the problem might have been happening though? I will definitely test your solution later today and get back to you if it does not work. Thanks again. – Tamim J Jun 16 '16 at 14:54
  • Just tested it and it doesn't work. Same error upon changing the Stage. – Tamim J Jun 16 '16 at 14:57
  • AND combines all the conditions. You may need to reverse some of them as they're presently written. If you want the Record Type to always be "Products and Services", then you need to use !=. Same goes for your Order_Sub_Type__c. You need to include all the possible values you don't want to have or exclude the ones you DO want to have. – crmprogdev Jun 16 '16 at 15:02
  • but wouldn't you say that if I want the rule to fire only on Products and Services Record Types or those that are Order Sub Type Contract Renewal, I should have them in positive statements? This rule fires if the Total Deal Price doesn't equal the Product Roll Up ONLY on Product and Services or Contract Renewal Opportunities in those displayed Stages. – Tamim J Jun 16 '16 at 15:49
  • Same issue. You're validating that the record type is = Products and Services. To do that, the test has to be != 'Products and Services'. Your logic in your validation rule is flawed. Ditto for any other fields that must match. You have to test for the opposite being true. – crmprogdev Jun 16 '16 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.