Validation Rules & Formulas

Writing field validation rules on objects.  You can create a formula field as a custom field. You can also create a formula field as a validation rule.

Note: There are more than one way to write the AND() function. You can write it as a function with AND() or as an operator by linking two statements with &&. Example: AND(DoNotCall, HasOptedOutOfEmail) is equivalent to DoNotCall && HasOptedOutOfEmail.

Make sure not to mix up &&, which replaces AND(), with &, which concatenates two text strings. This is the OR() function and || is the operator. This is NOT() function and can also be written as a simple exclamation point as !

Instead of stringing together logical operators like AND() and OR(), you could use IF() statements. IF() takes three arguments, in the format IF(test, result, alternate). Like ff test is true, evaluate result. Else, evaluate alternate.

This formula checks if the contact has selected Do Not Call. If the contact hasn’t, the formula ensures that the phone number field isn’t blank: IF(NOT(DoNotcall), NOT(ISBLANK(Phone)), false)

Logical operators, just like mathematical operators, have an order of operation. AND() is always evaluated before OR(). You can also group logical operators in parentheses to have them evaluated in a particular order.

See more: