0

I want to make some fields required, if the Opportunity is closed won. So I tried the following code, but it does not trigger, so the AND seems to be always false, but I do not know why.

AND(
ISPICKVAL( StageName , "08 - Closed Won"),    Order_Form_uploaded__c,
Contract.Contract_uploaded__c,   
NOT(ISPICKVAL( Account.Type , "Customer")),
NOT(ISPICKVAL(  Account.Account_Status__c , "4  Avoid: Current Client")),
ISBLANK(PO_Date__c),
ISBLANK( Licensing_Start__c ),
ISBLANK( Quote_Number__c ),
NOT(HasOpportunityLineItem  ) 
)

This are my requirements: IF Opp is closed won and contract_uploaded tickbox is true, order_form Tickbox is true, Account Type = Customer, Account Status = 4 Avoid: Current Client, PO Date is not null, Quote number is not null and At least one product is added, then show error message

I have checked all fields but nothing happens.. Is it possible that the problem is related to some fields not yet "created"? Will ISBLANK(Quote_Number__c) return true if there is no such record created yet?

Thanks!

1
  • Do you know which condition is false? Troubleshooting 101 says you need to isolate each condition and know for certain what it's value is.
    – Nick C
    Jan 27, 2021 at 21:59

1 Answer 1

1

You've confused AND and OR with how we typically use the words in English. In Boolean logic, AND means all conditions must be met, while OR means any condition must be met. Since you're checking if any of several fields are blank, you want an error if any of those fields are blank, while as written, this validation rule will only show an error if all of those fields are blank.

As an aside, you should consider separate validation rules for each field. This allows you to place the error on the appropriate field(s) that the user needs to fill out. You are allowed hundreds of validation rules per object, so there's no need to "conserve" them.

Your rule should probably read:

AND(
  ISPICKVAL( StageName , "08 - Closed Won"),
  NOT(ISPICKVAL( Account.Type , "Customer")),
  NOT(ISPICKVAL(  Account.Account_Status__c , "4  Avoid: Current Client")),
  OR(
    Order_Form_uploaded__c,
    Contract.Contract_uploaded__c,   
    ISBLANK(PO_Date__c),
    ISBLANK( Licensing_Start__c ),
    ISBLANK( Quote_Number__c ),
    NOT(HasOpportunityLineItem  ) 
  )
)
1
  • Thanks for your help! I seperated it in multiple validation rules, which are working great. But the rule, which should check if a field on the Contract object is ticked is not working. This is my rule: AND( ISPICKVAL( StageName , "08 - Closed Won"), NOT(Contract.Contract_uploaded__c) ) What is the problem with the Contract object?
    – Dennis1995
    Feb 3, 2021 at 11:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .