You have three key issues:
- You need to use
<
instead of <>
.
- You cannot call
LEN
on a Number
.
- You need to use
OR
instead of AND
.
1. Less Than <> Not Equal
If you want to set a minimum length, you need to use the <
operator. You need less than
to validate the length doesn't go below your threshold rather than not equal
.
Use >
for greater than
.
Use <>
for not equal
.
Use <
for less than
.
2. Number <> Text
You are trying to treat numbers as text.
The correct way to check if a number is blank:
ISNULL(NumberField__c)
The correct way to check if a numeric text field is blank:
ISBLANK(NumericTextField__c)
The correct way to check if the length of a number is less than 4:
NumberField__c < 1000
The correct way to check if the length of a numeric text field is less than 4:
LEN(NumericTextField__c) < 4
3. OR <> AND
If you use the checks on length described in #2, it is impossible for both criteria to be true at the same time. The following formula should work for a number field:
OR(
ISNULL(NumberField__c),
NumberField__c < 1000
)
The following should work for numeric text:
OR(
ISBLANK(NumericTextField__c),
LEN(NumericTextField__c) < 4
)
The above formula for number results in:
record.NumberField__c = null; // validation error
record.NumberField__c = 0; // validation error
record.NumberField__c = 10; // validation error
record.NumberField__c = 100; // validation error
record.NumberField__c = 1000; // valid
record.NumberField__c = 10000; // valid
record.NumberField__c = 100000; // valid
record.NumberField__c = 1000000; // valid
The above formula for numeric text results in:
record.NumericTextField__c = null; // validation error
record.NumericTextField__c = ''; // validation error
record.NumericTextField__c = '10'; // validation error
record.NumericTextField__c = '100'; // validation error
record.NumericTextField__c = '001'; // validation error
record.NumericTextField__c = '0001'; // valid
record.NumericTextField__c = '1000'; // valid
record.NumericTextField__c = '10000'; // valid