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
raj123raj123 

vALIDATION RULE

i have a requirement to validate a text field which contains text in the following format 

 

XXXX-(mmddyy)todays date - 12345(5)digits or xxxxx_xxxxxx--(mmddyy)todays date - 12345(5)digits

 

 

NOT(
OR(
Formula:
LEN (XXXXXXXXXX__c) = 0,
REGEX( XXXXXXXXXXX__c , "XXXXXXXXXX-[0-9]{6}-[0-9]{5}")

 

can any one help me with the first one to check for the underscore inbetween 

thanks

goabhigogoabhigo

Can you explain bit more with some example?

raj123raj123

i want a formula or regex to validate a field on a XXX object which composed of  three parts 

 

1. Is  a identification code  cosider IND or IND_FLEX, IND_CEVR, like this 

2. todays date in this format mmddyy

3 . is a 5 digit serial no 

 

Altogether combined in 1-2-3 format

 

i need a formula to validate this as initially i thought it would be done by regex since the id code field is not of fixed length, but it cannot be done by regex

 

can you help me with formula  to validate this field 

goabhigogoabhigo

In validation rule try:

 

NOT( REGEX(xxx__c, [A-Z]{3}_[A-Z]{4}-[0-9]{6}-[0-9]{5}) )

 

This will check for the format also will not allow blank. If you need to allow blank, then,

OR( ! ISBLANK(xxx__c), ! REGEX(xxx__c, [A-Z]{3}_[A-Z]{4}-[0-9]{6}-[0-9]{5}) )

 

Note that the mmddyy format will not be checked properly, since we are just saying allow digits upto 6 in length ( [0-9]{6} ). You might need to add something as below:

For month--->  [0]{1}[1-9]{1}||[1]{1}[0-2]{1}....