Loading

Formula field exceeds maximum number of characters

Julkaisupäivä: May 6, 2026
Kuvaus

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

  1. The code in a Formula Field can exceed the maximum number of characters allowed in two ways:
    1. Directly in the Formula Field's characters (3,900 character limit)
    2. In the overall size of the formula after other included formula fields are factored in (5,000 byte limit)
  2. The formula (code) of other formulas is inserted where those other formula fields are included. For example:
    1. Field A contains the formula: "Total_Amount * .9"
    2. Field B contains the formula: "IF (Field_A__c = 0)..."
    3. Behind the scenes, B is expanded to: "IF ((Total_Amount * .9) = 0)..." because Formula_A's formula is placed into Formula_B, not Formula_A's result.
Ratkaisu

This article explains how formula fields in Salesforce can exceed character limits (3,900 characters directly, or 5,000 bytes when other formula fields are included) and provides several workarounds.

What to Do if Hitting This Limit

  1. Split the formula into two fields to resolve the smaller character limit (3,900). Create another formula field and move some portion of the code into it. Then call Formula_A within Formula_B. Each formula field can have up to 3,900 characters.
  2. Reduce the overall formula chain size. When a formula field refers to other formula fields (which may in turn refer to even more formula fields), the compounded code can exceed the 5,000-byte limit. Review the whole combination of formula fields to find anything that can be reduced or eliminated from the chain. Even a small reduction can have a ripple effect and significantly reduce overall size.
  3. Use Workflow (Enterprise Edition or Unlimited Edition only) to help work around the limit:
    1. Create a new hidden field not visible on any page layout.
    2. Create a new Workflow Rule that triggers when a record is Created or Edited, with a criteria that is always true (for example: Owner Name not equal to NULL).
    3. Create an Immediate Workflow Action that performs a Field Update to the newly created hidden field.
    4. Click Use a formula to set new value and enter the name of the first formula field (Formula_A). Whenever a record is created or edited, Formula_A's results will be calculated and copied into this new regular field. Then reference this field instead of Formula_A within Formula_B.
    5. Note: You must manually update existing records for the updated values to be applied.
  4. Use Apex code (Enterprise Edition or Unlimited Edition) to trigger an update to a field on the record. This provides more powerful and flexible options, including the ability to assign values based on procedural algorithms (for example, a double-declining balance) and to reference values beyond the record or object being evaluated in a formula or workflow, similar to the VLOOKUP() function that can be used in a validation rule but not in a custom formula field.
  5. Use the CONTAINS function where possible. For example, when comparing multiple picklist values, use CONTAINS(AB:AC:AD:AE) based on the requirement.

Best Practice

For best results when referencing multi-level nested formula fields, split the overall code approximately in half near the middle of the formula field chain. This reduces the formula size to fit within character limits. Also, do not include Roll-Up

Please see the Tips for reducing formula size.

Please see Formula Field Limits and Restrictions and Process Formula Limitations for other information.

Knowledge-artikkelin numero

000385147

 
Ladataan
Salesforce Help | Article