How to create object validation rules

With validation rules, you can create if-else statements to ensure certain conditions are met before saving your records. You can create validation rules for both standard objects and custom objects.

Before you create your validation rule, determine what object type and fields you want to create the rule for. If you're not familiar with C# (C sharp) or any C programming language, you'll want to get assistance from someone who is more familiar with coding.

To create a validation rule:

  1. Click the profile icon and click System Settings.
    _4a977cf23a58e5bb5b117caebb141e4d__Image_2018-11-27_at_3.11.22_PM.png
  2. Click Objects and Fields.

  3. Select the object you want to create the rule for. 

  4. Click Validation Rules and click New Rule. 
    2018-12-12_13h18_04.png
  5. Complete the required fields:
    • Rule Name – Enter the name for your rule. For example, we are going to create a new rule for contacts called The first name can't equal test.
    • Error Message - Type the message you want to display when your rule is met.

  6. Select the Error Location for your message. Based on your selection, that is where the error message will display on the record's page. For example, if you select Top of Page, your message will display at the top of the record.
    2018-12-12_13h22_28.png
  7. Enter your formula in the Rule Formula field. To help build the formula, click the Helpers button. You can add values to the formula box by double-clicking or dragging any item from the Objects Fields or Functions list, typing directly in the field, or by copying and pasting a provided formula, such as the examples at the end of this article.

    Under Object Fields, the different record fields are sorted by type. For example, if you want to view the string fields (text), select String Fields. The Functions list is also sorted by their function types, such as Boolean (True or False), DateTime, and Decimal.

    Here is an example of a formula for contacts. This formula checks whether an email is present and whether that email is valid by checking if it has the @ symbol.

    if (Record.EMAIL_ADDRESS != null && EMAIL_ADDRESS.Contains("@")) {
     return Validation.IsValid;
    } else {
     return Validation.IsError;
    }

    To learn more about the functions, click any function and read the description.

    To ensure your rule is met, the return statements need to include one of the two validations:

    • Validation.IsError to return your error message.
    • Validation.IsValid to determine the error is clear.

  8. Click Validate Formula to check your formula can compute. If Insightly cannot validate your formula, an error message will display above the formula field stating why.

  9. Click Create Validation Rule.
To save the validation rule, you must return a value and validate the formula.
Was this article helpful?