Examples for how to validate that users can't save a time card record with more than
40 hours in a work week, numbers can't be negative, and even or odd numbers.
| Available in: both Salesforce Classic and Lightning Experience |
| Available in: Contact Manager, Group, Professional,
Enterprise, Performance, Unlimited, Developer,
and Database.com Editions |
Time Cards Must Total 40 Hours
|
Description:
|
Ensures that users cannot save a time card record with more than 40
hours in a work week. This example requires five custom fields on your
custom object, one for each day of work. |
| Formula: |
1Monday_Hours__c +
2Tuesday_Hours__c +
3Wednesday_Hours__c +
4Thursday_Hours__c +
5Friday_Hours__c > 40
|
| Error Message: |
Your total hours cannot exceed 40. |
| Error Location: |
Top of Page |
Number Cannot Be Negative
|
Description:
|
Validates that a custom field called Hours Worked
is not a negative number. |
| Formula: |
|
| Error Message: |
Hours Worked cannot be less than zero. |
| Error Location: |
Hours Worked |
Number Must Be Even
|
Description:
|
Validates that a custom field called Ark Passengers
is a non-negative even number. |
| Formula: |
1OR(
2 Ark_Passengers__c < 0,
3 MOD( Ark_Passengers__c, 2) <> 0
4)
|
| Error Message: |
Ark Passengers must be a positive even number. |
| Error Location: |
Ark Passengers |
Number Must Be Odd
|
Description:
|
Validates that a custom field called Socks Found is
a non-negative odd number. |
| Formula: |
1OR(
2 Socks_Found__c < 0,
3 MOD( Socks_Found__c, 2) = 0
4)
|
| Error Message: |
Socks Found must be an odd number. |
| Error Location: |
Socks Found |
Number Must Be a Multiple of Five
|
Description:
|
Validates that a custom field called Multiple of 5
is a multiple of five. |
| Formula: |
1MOD( Multiple_of_5__c, 5) <> 0
|
| Error Message: |
Number must be a multiple of five. |
| Error Location: |
Multiple of 5 |
Number Must Be an Integer
|
Description:
|
Validates that a custom field called My Integer is
an integer. |
| Formula: |
1FLOOR( My_Integer__c) <> My_Integer__c
|
| Error Message: |
This field must be an integer. |
| Error Location: |
My Integer |
Number Must Be Between -50 and 50
|
Description:
|
Validates that a custom field called Volume is
between -50 and 50. |
| Formula: |
|
| Error Message: |
Volume must be between -50 and 50. |
| Error Location: |
Volume |
Number Range Validation
|
Description:
|
Validates that the range between two custom fields, Salary
Min and Salary Max, is no greater than
$20,000. |
| Formula: |
1(Salary_Max__c - Salary_Min__c) > 20000
|
| Error Message: |
Salary range must be within $20,000. Adjust the Salary Max or Salary Min
values. |
| Error Location: |
Salary Max |
Percentage Must Be Between Zero and 100
|
Description:
|
Validates that a custom field called Mix Pct is
between 0 and 100%. Note that percent fields are expressed divided by 100 in
formulas (100% is expressed as 1; 50% is expressed as 0.5). |
| Formula: |
1OR(
2 Mix_Pct__c > 1.0,
3 Mix_Pct__c < 0.0
4)
|
| Error Message: |
Mix Pct must be between 0 and 100%. |
| Error Location: |
Mix Pct |