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
BarakBarak 

Concatenate 0 if length is 7

I want to create a validation rule that trigger:

If length of ARC Number_C is 7 then concatenate 0 to the ARC Number_C.

I am trying following equation:

IF( LEN( ARC_Number__c ) = "7" ,"0" & ARC_Number__c   ,  ARC_Number__c )

But fail and receives a error message"

Error: Incorrect parameter type for function 'LEN()'. Expected Text, received Number

 

Thanks,

Naveen 

CheyneCheyne

You probably want a workflow rule. A validation rule cannot perform field updates. 

 

You are receiving an erorr because the LEN() function operates on Text. You must convert ARC_Number__c to text first, and then apply the LEN() function. So your workflow rule criteria would be 

LEN(TEXT(ARC_Number__c))=7

 Then you would create the following field update on ARC_Number__c, associated with that workflow rule:

"0" & TEXT(ARC_Number__c)

 That would prepend a 0 to ARC_Number__c if the length of ARC_Number__c is seven (that is, has seven digits).