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
VKrishVKrish 

Simple Validation Rules Not working

I am trying to validate a text field that should be a valid year - only numeric, only 4 digits, values from 1900 - current year.

My logic is:

OR(

IF (not(isblank(YEB__c)), Not(isnumber(YEB__c)), NULL),

IF (Len(YEB__c) <> 4, not(isblank(YEB__c)), NULL),

VALUE(YEB__c) < 1900,

VALUE(YEB__c) > year(today()) )

 

Values not between 1900 - current year is working. But Not(Isnumber(YEB__c)) or Len(YEB__c) <> 4 is not working

I tried to split things and tried these 2:

Not(Isnumber(YEB__c)) alone one time and

Len(YEB__c) < 4 alone another time.

Both compiles (allows me to save), but doesn't work in the sandbox. The simple Len(fieldname) checks shows error if left blank. But it passes even if I enter 1 digit.

Any Ideas?

Best Answer chosen by Admin (Salesforce Developers) 
VKrishVKrish

Finally found the issue:

I copied the same formula in another version of salesforce sandbox and it works

It works in the salesforce Winter 2012 version

But not in Spring 2012 version (in which my sandbox is currently upgraded to & where I am developing)

 

Anyway in couple of months my older version will be automatically upgraded to Spring 2012 version!

Actually there is problem with many of the simple functions in newer Spring 2012 version!

 

It would be great if salesforce fixes these small issues before the upgrade.

All Answers

WorkhardWorkhard

Hi,

Use this validation rule

VALUE( YEB__c ) < 1900 || VALUE( YEB__c) >= YEAR( DateValue(CreatedDate) )

 

VKrishVKrish

Thanks for the reply!

Function Value() is working the way I wanted if I enter 4 digit value. It fails if I enter 3 digits.

I dont understand this: if the function can check 1850 < 1900, why cant it check 880 < 1900?

Also Not(Isnumber()) and len() functions are not working for me in sandbox.

Btw, my text field has max length 4. Does that have to do something with the functions not working?

WorkhardWorkhard

Hi,

Its working at my end.I am geting the error message if i take the value of text field as 850.

VKrishVKrish

Thats bizarre! How come it is not working in my system alone!

Currently, I tried something similar to what you said,

not(isblank(YEB__c)) && (

NOT(ISNUMBER(YEB__c)) ||

VALUE( YEB__c ) < 1900 ||

VALUE( YEB__c) > YEAR(DateValue(CreatedDate)) )

 

Now it checks for alphabets (which was not working in my previous logic) & if I enter 4 digit numbers.

It fails if I enter 3 digit or 5 digit number (I modified the length of the text field to 20 assuming that might be a problem)

 

Where am I going wrong?

VKrishVKrish

Finally found the issue:

I copied the same formula in another version of salesforce sandbox and it works

It works in the salesforce Winter 2012 version

But not in Spring 2012 version (in which my sandbox is currently upgraded to & where I am developing)

 

Anyway in couple of months my older version will be automatically upgraded to Spring 2012 version!

Actually there is problem with many of the simple functions in newer Spring 2012 version!

 

It would be great if salesforce fixes these small issues before the upgrade.

This was selected as the best answer