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
Aaron MosseyAaron Mossey 

Need a Formula that evaluates a number value and ensures output is always at least 4 digits.

For example:

Input value = 3
then output = 0003

Input value = 64
then output = 0064

Input value = 3269
then output = 3269

Is this possible?
Best Answer chosen by Aaron Mossey
Alain CabonAlain Cabon
Input value = 3
then output = 0003

RIGHT ( LPAD( text__c , 4, '0') , 4 )
 

All Answers

Raj VakatiRaj Vakati
If you change your input type to the text its possible just with configuration .. 

You can use workflow to update the second field .. but with number i guess NO 
Aaron MosseyAaron Mossey
Thanks Raj, but this input or reference field is populated by auto number helper app and their config is very limited including not being able to apply leading zeros.  What I'm looking to do is correct for this with a cascaded text field that is updated via a workflow/field update formula that can manage a char count and add zeros if source value is less than 4 char.  I know how to hardcode leading zeros with an LPAD function but that does not solve for my problem due to it being tied to a counter and requiring output to be locked to 4 characters.
Alain CabonAlain Cabon
"hardcode leading zeros with an LPAD function"

Why LEN, LPAD, RIGHT (+TEXT) are not sufficient for your padding?

You have numbers above 9999?
 
Aaron MosseyAaron Mossey
No numbers above 9999, we reset at that point.  Our GL only accepts a 6 digit ID including a locked 2 char prefix so the number counter can never exceed 9999.  I think those functions can work, I'm just not sure how to combine them to desired effect.
Alain CabonAlain Cabon
Input value = 3
then output = 0003

RIGHT ( LPAD( text__c , 4, '0') , 4 )
 
This was selected as the best answer
Aaron MosseyAaron Mossey
Thanks Alain,

That works just great