function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bzain9bzain9 

Validation Rule: Length Must be 9 Digits, and 9 Digits only, (it is a text field). AND the value should also be able to save (not fire error message) if there is no value in the field (NULL)

Validation Rule: Length Must be 9 Digits, and 9 Digits only, (it is a text field). AND the value should also be able to save (not fire error message) if there is no value in the field (NULL). I have tried several attempts, and while testing the validation rule, I have not been able to get the Null Value part to work. Validation error message is firing for 9 Digits only, and be restricted to 9 digits only, but not null... Any help would be awesome!

OR(
     NOT(
         ISNUMBER(
                  Employer_ID_No_EIN__c
                 )
        ),
    AND(
        NOT(
            ISBLANK(
                     Employer_ID_No_EIN__c
                   )
           ),   
       
        
        ISNUMBER(Employer_ID_No_EIN__c), 
        LEN(Employer_ID_No_EIN__c) <>9
          
       )
)
Best Answer chosen by bzain9
Steven NsubugaSteven Nsubuga
Try this
IF ( 
	NOT(ISBLANK(Employer_ID_No_EIN__c)), OR(LEN(Employer_ID_No_EIN__c) <>9, NOT(
         ISNUMBER(Employer_ID_No_EIN__c))), false
)

 

All Answers

Steven NsubugaSteven Nsubuga
Try this
IF ( 
	NOT(ISBLANK(Employer_ID_No_EIN__c)), OR(LEN(Employer_ID_No_EIN__c) <>9, NOT(
         ISNUMBER(Employer_ID_No_EIN__c))), false
)

 
This was selected as the best answer
bzain9bzain9
Hey Steven, the above allows to save if there is no value in the field, but now the validation on making the field as a number only, and that it must be a length as 9 only doesn't work now.
Steven NsubugaSteven Nsubuga
IF ( 
	NOT(ISBLANK(Employer_ID_No_EIN__c)), AND(LEN(Employer_ID_No_EIN__c) <>9, NOT(
         ISNUMBER(Employer_ID_No_EIN__c))), false
)

 
bzain9bzain9
Same problems as above
Steven NsubugaSteven Nsubuga
IF ( 
NOT(ISBLANK(Employer_ID_No_EIN__c)), LEN(Employer_ID_No_EIN__c) <> 9, false 
)

 
bzain9bzain9
Thanks, I figured out the issue!
Nolan VanNurdenNolan VanNurden

IF ( NOT(ISBLANK(Employer_ID_No_EIN__c)), LEN(Employer_ID_No_EIN__c) = 9, false )