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
Rachel Linder 20Rachel Linder 20 

Receiving Compile Size Error When Creating a New Formula Field

I am creating a formula field that is totally 4 other formula fields and receiving the following error: "Error: Compiled formula is too big to execute (7,784 characters). Maximum size is 5,000 characters"

Here is the formula I am creating:
ARR_New__c  +  ARR_Price_Change_RN__c  +  ARR_Quantity_Change_RN__c  +  ARR_Removed__c
How can I reduce the compile size?

Here is what each one of the 4 formula fields above looks like:

ARR NEW (Compiled Size: 730 Characters)
IF(ISPICKVAL(Opportunity.StageName,"Closed Lost"),0,
       If( 
          AND 
            (NOT 
                (Line_Level_Detail__c='Services'), Line_Level_Type__c= 'New Product'), UnitPrice * Quantity , 0))
ARR Price Change (RN) (Compiled Size: 2,738 characters)
If (
    ISPICKVAL(Opportunity.StageName,"Closed Lost"),0,
IF( 
   AND(
       Line_Level_Type__c= 'Renewed Product',  NOT(CONTAINS( Pricing_Method_Change__c, 'Block'))),  Quantity *( UnitPrice - Renewed_Subscription_Net_Price__c),
IF(
   AND(
       Line_Level_Type__c= 'Renewed Product', CONTAINS( Pricing_Method_Change__c, 'Block')), TotalPrice - Renewed_Subscription_Total_Amount__c, 0)
)
)
ARR Quantity Change (RN) (Compiled Size: 1,345 characters)
IF(
    ISPICKVAL(Opportunity.StageName,"Closed Lost"),0,
IF(
    AND(Line_Level_Type__c='Renewed Product', NOT(CONTAINS( Pricing_Method_Change__c, 'Block'))),
         Renewed_Subscription_Net_Price__c *( Quantity  -  Quantity_Upon_Creation__c ),0))
ARR Removed (Compiled Size: 2,925)
IF (
    AND(
         (ISPICKVAL(Opportunity.StageName, "Closed Lost")), Line_Level_Type__c  <>  'New Product'), Combined_Renewed_Subscription_Total_Amt__c  *-1,
            IF (
              AND(
                 Line_Level_Type__c = 'Removed Product', Opportunity_Record_Type__c = 'Amendment',  Line_Level_Detail__c  <> 'Services'), TotalPrice,
                   IF (
                      AND (
                           Line_Level_Type__c = 'Removed Product', Opportunity_Record_Type__c = 'Renewal'),  Combined_Renewed_Subscription_Total_Amt__c  *-1,0)
)
)

 
Alain CabonAlain Cabon

Line_Level_Detail__c  and Line_Level_Type__c are very likely also formulas because the compiled size are impressive for these simple tests.

Are they formulas?
Rachel Linder 20Rachel Linder 20
@Alain Cabon - nope those are actually picklist fields.
Alain CabonAlain Cabon
And the following fields?
  • Pricing_Method_Change__c
  • Combined_Renewed_Subscription_Total_Amt__c  
  • Quantity_Upon_Creation__c 
  • Renewed_Subscription_Net_Price__c 
Rachel Linder 20Rachel Linder 20
  1. Pricing_Method_Change__c - formula
  2. Combined_Renewed_Subscription_Total_Amt__c  - formula
  3. Quantity_Upon_Creation__c - this is a field update via process builder
  4. Renewed_Subscription_Net_Price__c - formula
Alain CabonAlain Cabon
 
  • Pricing_Method_Change__c - formula
  • Combined_Renewed_Subscription_Total_Amt__c  - formula
  • Renewed_Subscription_Net_Price__c - formula
The current formulas are perfect (including the first sum) for the clarity but the several calls of the three fields above must be reduced as far as possible because the compiler of the formulas is not clever and cumulates the code of the sub-formulas for each call.

A big unique formula with all the tests and the miminal number of calls for the formula fields (very consuming) could be tried.

A big unique formula:
IF(ISPICKVAL(Opportunity.StageName,"Closed Lost"),0,
       If( 
          AND 
            (NOT .....
instead of:
ARR_New__c  +  ARR_Price_Change_RN__c  +  ARR_Quantity_Change_RN__c  +  ARR_Removed__c

But even with a big unique formula (given that the tests are not very heavy in the compiled formula and if the number of use of the formula fields remains the same), the final size could be still too big;

The last option in that case is to update via process builder other fields (bad news) that will be not formulas anymore.
 
Alain CabonAlain Cabon
So you need also to simplify the number of use for the fields inside the formula fields themselves like Combined_Renewed_Subscription_Total_Amt__c   that the contents are not posted.