Print this page

Formula Field exceeds maximum number of characters

Knowledge Article Number 000005456
Description
The code in a Formula Field can exceed the maximum number of characters allowed. Learn the two ways this can happen, below. 
 

1. The code in a Formula Field can exceed the maximum number of characters allowed in two ways:
 

  • Directly in the Formula Field's characters (3900).
  • In the overall size of the Formula after other included Formula Fields are factored in (5000) bytes.

 

2. The latter of those problems can result from the formula (code) of other formulas being inserted where those other formula fields are included. For example:
 

  • Field A says "Total_Amount * .9"
  • Field B says "IF (Field_A__c = 0)..."
  • Then behind the scenes, B is expanded to say "IF ((Total_Amount * .9) = 0)..." because Formula_A's formula is put into Formula_B, not Formula_A's result
Resolution

 

What to do if you run into either limit

 

1. The smaller character limit (3900) can be remedied by splitting the formula into 2 fields. Create another formula field and break out some part of the code into that one. Then call Formula_A within Formula_B. Each can have up to 3900 characters.

 

2. The trickier case is when a formula field that refers to other formula fields (that may in turn refer to even more formula fields) results in compounded code which exceeds the 5000 bytes limit. In any edition, the whole combination of formula can be scrutinized to see if there is anything that can be reduced or eliminated from the string of code. Any small part might have a ripple effect and significantly reduce the overall size.

 

3. In Enterprise (EE) or Unlimited Edition (UE) Workflow can be used to help out.

Here's how: 

 

1. Create a new hidden field (not visible on any Page Layout).
2. Create a new Workflow Rule for the object which triggers when record is Created or Edited and make the Criteria something that is always true, like Owner Name <not equals> NULL.
3. Make an Immediate Workflow Action which does a Field Update to the newly created (hidden) field. 
4. Click Use a formula to set new value.
5. For the formula, enter the name of the first Formula Field (Formula_A). Any time a record in this object is created or edited, Formula_A's results will be calculated and copied into this new. regular field. Then refer to this field instead of Formula_A within Formula_B.


Best Practice: For best results on multi-level nested Formula Field references, pick a spot near the middle of the chain of Formula Fields to split the overall code in half. This will reduce the size more quickly. Please see the Tips for reducing formula size

 

4. Apex code could also be used in (EE, UE) to trigger an update to a field on the record. This provides even more powerful and flexible options, including the capability to assign values based on procedural algorithms (e.g., a double-declining balance) and to reference values beyond the record/object that is being evaluated in a formula or workflow, similar to the VLOOKUP() function--that can be employed on a validation rule but not in a custom formula field.





promote demote