When you create custom fields and Page Layouts, you can mark fields as required. You may want to set other types of rules for your records before they can be saved.
With object validation rules, administrators can write formulas to verify that certain conditions are met before records are saved. You can create validation rules for all standard and custom objects.
Like calculated fields, formulas are written using C# (C sharp) and must return a Boolean value (true or false). If you're not familiar with C# or any C programming language, get assistance from someone who is.
You can write your formula using if-else statements, but your statements cannot contain:
- for loops
- do while loops
- method declarations
The formula below is an example of an if-else statement:
if (Record.FIRST_NAME == "Test")
{
return true;
} else {
return false;
}
According to this if-else statement, the first name field for a contact record cannot be equal to the word test.
In addition to if-else statements, the contains () method can also be utilized. The formula below is an example of the contains () method:
// Get value of field, or "" if the field is null
var test = Record.ASSISTANT_NAME ?? String.Empty;
if( test.Contains("Test") )
{
return Validation.IsError;
} else {
return Validation.IsValid;
}
You can create custom error messages when rules are not met, such as letting users know that "test" is not a valid entry for the first name field.
Data validation rules only apply to the web application of Insightly, not sidebars or add-ons.
Validation rules can also be used to prevent other users from editing records they don't own.
Check out our webinar recording on Securing and Protecting your Data with Validation Rules and Advanced Permissions.