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
Ruwantha  LankathilakaRuwantha Lankathilaka 

Validation Rule LEN function

When writing a validation rule in a custom object field is it required to drop the global relationship inside the LEN (text) function?
eg LEN( $ObjectType.Customer__c.Fields.ID_Number__c )  gives error "Error: Incorrect parameter type for function 'LEN()'. Expected Text, received Object"

But when I put it LEN(ID_Number__c ) it works fine!!!
Waqar Hussain SFWaqar Hussain SF
Hello Ruwanthalk..
Use this in you validation rule..
LEN(TEXT($ObjectType.Customer__c.Fields.ID_Number__c))

let me know if it works
Ruwantha  LankathilakaRuwantha Lankathilaka
Thanks Vickey,

But then it says Error: Incorrect parameter type for function 'TEXT()'. Expected Number, Date, DateTime, Picklist, received Object
Waqar Hussain SFWaqar Hussain SF
what condotion are you using. can you share complete condition. I think you have to use other funtions for validation..
use this it would work for you.
ISBLANK($ObjectType.Customer__c.Fields.ID_Number__c)

 
Ruwantha  LankathilakaRuwantha Lankathilaka
It seems LEN() is not getting it correctly
ISBLANK($ObjectType.Customer__c.Fields.ID_Number__c)
works fine
but
LEN($ObjectType.Customer__c.Fields.ID_Number__c)
will give

Error: Incorrect parameter type for function 'LEN()'. Expected Text, received Object
 
Waqar Hussain SFWaqar Hussain SF
Because you are giving the ID in the LEN() funtion, it means you give an object, the method can not find the length of the object. it can calculate the length of text, date, Number, DateTime, and Picklist.