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
uzairuzair 

Getting "Compiled formula is too big to execute" error

 Hi All,

 

I'm in a situation where I have written the formula for a formula field and I'm getting the below given error :

"Compiled formula is too big to execute (76,352 characters). Maximum size is 5,000 characters"

 

In the below formula 'Product_Name__c' and 'New_Supplier__c'  are picklist fields; 'Proposed_Supply_Start_Date__c' and 'Postage_Date__c' are date fields; 'Contract_Term_Months__c' is a number field; 'Amount' is the standard amount field of opportunity and 'Acquisition_Renewal__c' is a text field.

 

Here goes my formula :

 

IF(
  AND(  ISPICKVAL(  New_Supplier__c , "British Gas Business"),
    ( Proposed_Supply_Start_Date__c <  DATE(2012,05,01) ),
    ( Contract_Term_Months__c = 12)
  )
  ,  (Amount  * 0.8 ),
  IF(
   AND(  ISPICKVAL(  New_Supplier__c , "British Gas Business"),
     ( Proposed_Supply_Start_Date__c <  DATE(2012,05,01) ),
     ( Contract_Term_Months__c = 24)
   )
   ,  ((Amount/2)  * 0.8 ),
   IF(
    AND(  ISPICKVAL(  New_Supplier__c , "British Gas Business"),
      ( Proposed_Supply_Start_Date__c <  DATE(2012,05,01) ),
      ( Contract_Term_Months__c = 36)
    )
    ,  ((Amount/3)  * 0.8 ),
    IF(
     AND(  ISPICKVAL(  New_Supplier__c , "Eon"),
       ( Proposed_Supply_Start_Date__c <  DATE(2012,05,01) ),
       ( Acquisition_Renewal__c = "Renewal" ),
       ( CONTAINS( TEXT(Product_Name__c ), "Access") ),
       ( Contract_Term_Months__c = 36)
     )
     ,  (Amount),
     IF(
      AND(  ISPICKVAL(  New_Supplier__c , "Eon"),
        ( Proposed_Supply_Start_Date__c <  DATE(2012,05,01) ),
        ( Acquisition_Renewal__c = "Acquisition" ),
        ( CONTAINS( TEXT(Product_Name__c ), "Connect") ),
        ( Contract_Term_Months__c = 12)
      )
      ,  (Amount  * 0.6 ),
      IF(
       AND(  ISPICKVAL(  New_Supplier__c , "Eon"),
         ( Postage_Date__c  <  DATE(2012,05,01) ),
         ( Acquisition_Renewal__c = "Renewal" ),
         ( CONTAINS( TEXT(Product_Name__c ), "Connect") ),
         ( Contract_Term_Months__c = 12)
       )
       ,  (Amount  * 0.6 ),
       IF(
        AND(  ISPICKVAL(  New_Supplier__c , "Eon"),
          ( Proposed_Supply_Start_Date__c  <  DATE(2012,05,01) ),
          ( Acquisition_Renewal__c = "Acquisition" ),
          ( CONTAINS( TEXT(Product_Name__c ), "Connect") ),
          ( Contract_Term_Months__c = 24)
        )
        ,  (Amount  * 0.5 ),
        IF(
         AND(  ISPICKVAL(  New_Supplier__c , "Eon"),
           ( Postage_Date__c  <  DATE(2012,05,01) ),
           ( Acquisition_Renewal__c = "Renewal" ),
           ( CONTAINS( TEXT(Product_Name__c ), "Connect") ),
           ( Contract_Term_Months__c = 24)
         )
         ,  (Amount  * 0.5 ),
         IF(
          AND(  ISPICKVAL(  New_Supplier__c , "Eon"),
            ( Proposed_Supply_Start_Date__c  <  DATE(2012,05,01) ),
            ( Acquisition_Renewal__c = "Acquisition" ),
            ( CONTAINS( TEXT(Product_Name__c ), "Connect") ),
            ( Contract_Term_Months__c = 36)
          )
          ,  (Amount  * 0.4 ),
          IF(
           AND(  ISPICKVAL(  New_Supplier__c , "Eon"),
             ( Postage_Date__c  <  DATE(2012,05,01) ),
             ( Acquisition_Renewal__c = "Renewal" ),
             ( CONTAINS( TEXT(Product_Name__c ), "Connect") ),
             ( Contract_Term_Months__c = 36)
           )
           ,  (Amount  * 0.4 ),0
          )
         )
        )
       )
      )
     )
    )
   )
  )
 ) 

 

Any help to overcome this error will be highly appreciated.

 

Thanks in Advance.

 

ColinKenworthy2ColinKenworthy2

It seems very inefficient, you are doing the same checks over and over. Here is a suggestion you can finish it off... Even in this abbreviated version I can see the same things being checked twice. You should be able to refine it further.

 

IF(  AND(  ISPICKVAL( New_Supplier__c , "British Gas Business" ),
( Proposed_Supply_Start_Date__c < DATE(2012,05,01) )
 ),
( Amount * (12 / Contract_Term_Months__c) * 0.8 ),
   IF( AND(  ISPICKVAL( New_Supplier__c , "Eon" ),
         ( Proposed_Supply_Start_Date__c < DATE(2012,05,01) ),
          ( Acquisition_Renewal__c = "Acquisition" ),
         ( CONTAINS( TEXT(Product_Name__c ), "Connect") )
),
          ( Amount * (0.7 - (Contract_Term_Months__c/120)) ),

        IF(  AND(  ISPICKVAL( New_Supplier__c , "Eon" ),
                   ( Postage_Date__c < DATE(2012,05,01) ),
                   ( Acquisition_Renewal__c = "Renewal" ),
                   ( CONTAINS( TEXT(Product_Name__c ), "Connect") )
                 ),
                 ( Amount * (0.7 - (Contract_Term_Months__c/120)) ),

        IF(  AND(  ISPICKVAL(  New_Supplier__c , "Eon"),
                    ( Proposed_Supply_Start_Date__c <  DATE(2012,05,01) ),
                    ( Acquisition_Renewal__c = "Renewal" ),
                    ( CONTAINS( TEXT(Product_Name__c ), "Access") ),
                    ( Contract_Term_Months__c = 36)
                  ),
                 ( Amount ),
0
 )
)
)
)