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
lincylincy 

validatiin not working for number field

I have a entry code field i am trying a validation rule which says that it should contain only 7 numbers and adding user bypass and null check to it.But the formula is not working can any one suggest the fix.entry_code is a text(30) data type.

OR(AND($User.BypassValidation__c
NOT(ISNUMBER(entry_code__c)),
AND(ISNUMBER(entry_code__c)),
LEN(entry_code__c)<>7),(OR(entry_Code__c!="|| entry_Code__c!=NULL))
Best Answer chosen by lincy
VinayVinay (Salesforce Developers) 
Hi Lincy,

Try below snippet and it should work.
 
AND($User.BypassValidation__c, (OR(LEN(entry_code__c) <> 7, NOT(ISNUMBER(entry_code__c)))))

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar

All Answers

VinayVinay (Salesforce Developers) 
Hi Lincy,

Try below snippet and it should work.
 
AND($User.BypassValidation__c, (OR(LEN(entry_code__c) <> 7, NOT(ISNUMBER(entry_code__c)))))

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
This was selected as the best answer
Maharajan CMaharajan C
Hi Lincy,

Try the below anyone below formula.

AND( $User.BypassValidation__c = FALSE, 
(OR(LEN(entry_code__c) <> 7,
ISBLANK(entry_code__c))
)
)

===================

AND( $User.BypassValidation__c = FALSE, 
LEN(entry_code__c) <> 7,
)

Read the below two lines and decide whether we have to use TRUE or FALSE  in  $User.BypassValidation__c field check.

If the BypassValidation__c field is true then the bypass user should allow to save the record otherwise we have to throw the erroe means use $User.BypassValidation__c = FALSE in Formula

If the BypassValidation__c field is false then the bypass user should allow to save the record otherwise we have to throw the erroe means use $User.BypassValidation__c = TRUE in Formula


Thanks,
Maharajan.C
lincylincy
Thank@ vinay and @maharajan.How to include null check in the same validation formula here.Any help can be appreciated