1

I am creating a validation rule for an opportunity. Basically saying if you choose tick box A or tick box B then you must pick an option from the pick list.

I am new to the formulas and I have got it so my formula has 0 syntax errors but I cannot get the code to work.

OR(
AND(
 ISPICKVAL( Preferred_Subcontractor_Supplier__c, "" ),
  Supplier_Required__c = TRUE,Sub_Contractor_Required__c = TRUE ))

This should say, If sub contractor required is ticked OR supplier required is ticked AND no preferred supplier is selected from the pick list then an error message will generate.

  • Thanks everybody for their answers. Really appreciate the help! Anurag I used your method as it was the first I read and it works perfectly. Thank you :) – Paul Rogers Jun 8 '16 at 9:45
4

Try this:

AND(
    OR(
     sub contractor = true,
    supplier = true,

    ),
    ISPICKVAL(preferred supplier,""))
2

Simpler solution as checkbox fields are booleans and don't need to be compared to true or false.

AND(
   OR(Sub_Contractor_Required__c,
      Supplier_Required__c
   ),

   ISPICKVAL(Preferred_Subcontractor_Supplier__c, "" )
)

Note it can be useful best practice to name boolean fields similar to the way SFDC names checkbox fields Is_Subcontractor_required__c or Is_Supplier_Required__c. Labels can be, of course different.

1

You'll want your AND() clause outside OR().

AND(
   OR(Sub_Contractor_Required__c = TRUE,
      Supplier_Required__c = TRUE
   ),

   ISPICKVAL(Preferred_Subcontractor_Supplier__c, "" )
)

Conceptually, the formula in the OP says:

Show error if EITHER OF THESE( field_is_blank and BOTH OF THESE( type1, type2) )

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.