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
Mandy RawatMandy Rawat 

Error: Compiled formula is too big to execute (12,493 characters). Maximum size is 5,000 characters

I created a formula to change the lead created date into a working business hour i.e., 7:00 am to 4:00 pm. 
Lead Created system date             -->     Formula updated date
The formula field  Lead_In_Business_Hours__c is returning Date/Time value.

CASE(MOD( Lead_Created__c - DATE( 1900, 1, 8 ), 7 ), 
4, 
IF(AND ( 
TIMEVALUE(Created_Date_Time__c) >= TIMEVALUE('07:00:00.000'), 
TIMEVALUE(Created_Date_Time__c) < TIMEVALUE('14:00:00.000') 
), 
DATETIMEVALUE(TEXT(Lead_Created__c) & ' 14:00:00'), 
IF( OR (TIMEVALUE(Created_Date_Time__c) > TIMEVALUE('23:00:00.000'), 
AND(TIMEVALUE(Created_Date_Time__c) > TIMEVALUE('00:00:00.000'), 
TIMEVALUE(Created_Date_Time__c) < TIMEVALUE('07:00:00.000')) 
), 
DATETIMEVALUE(TEXT(Lead_Created__c + 3) & ' 14:00:00'), 
Created_Date_Time__c 

), 
5, DATETIMEVALUE(TEXT(Lead_Created__c + 2) & ' 14:00:00'), 
6, DATETIMEVALUE(TEXT(Lead_Created__c + 1) & ' 14:00:00'), 
IF(AND ( 
TIMEVALUE(Created_Date_Time__c) >= TIMEVALUE('07:00:00.000'), 
TIMEVALUE(Created_Date_Time__c) < TIMEVALUE('14:00:00.000') 
), 
DATETIMEVALUE(TEXT(Lead_Created__c) & ' 14:00:00'), 
IF(OR (TIMEVALUE(Created_Date_Time__c) > TIMEVALUE('23:00:00.000'), 
AND(TIMEVALUE(Created_Date_Time__c) > TIMEVALUE('00:00:00.000'), 
TIMEVALUE(Created_Date_Time__c) < TIMEVALUE('07:00:00.000')) 

), 
DATETIMEVALUE(TEXT(Lead_Created__c + 1) & ' 14:00:00'), 
Created_Date_Time__c 


)


This formula is working fine. Lead_Created__c is returning the DATEVALUE(Created_Date_Time__c)
Created_Date_Time__c is also a formula field returning CreatedDate.

I created another formula  FirstCallSinceLeadCreated__c to return the text value which  calculates the days,hours and minutes in between the lead created (in business hours)and the first call made to the lead.
FirstTaskDateTime__c stores Date/time of the first call made to a lead. It can be in non business hours.


IF(FirstTaskDateTime__c - Lead_In_Business_Hours__c > 0, 
TEXT(
FLOOR(FirstTaskDateTime__c -  Lead_In_Business_Hours__c)
) & " Day(s) " &
TEXT(
ROUND(MOD((FirstTaskDateTime__c  - Lead_In_Business_Hours__c )*24,24),0)
) &" Hour(s) " &
TEXT(
ROUND(MOD((FirstTaskDateTime__c  - Lead_In_Business_Hours__c )*1440,60),0)
) &" Minute(s) ", 
   IF((FirstTaskDateTime__c-Lead_In_Business_Hours__c)<0,
    TEXT(
          FLOOR(FirstTaskDateTime__c -  Lead_In_Business_Hours__c)) & " Day(s) " &
    TEXT(
         Floor(MOD((FirstTaskDateTime__c - Lead_In_Business_Hours__c) *24,24))) &" Hour(s) " &
     TEXT(
        ROUND(MOD((FirstTaskDateTime__c - Lead_In_Business_Hours__c)*1440,60),0)
        ) &" Minute(s) ",""
)
)

**This formula gives me an error Error: Compiled formula is too big to execute (12,493 characters). Maximum size is 5,000 characters
The same formula is working in workflow to update the field. But I want it through a formula field only. I tried breaking the formula and storing it to different fields but still getting the same error infact the characters are increasing.
Thanks in advance. 
krishnak2krishnak2
Hi Mandy,

It basically  means that there are either complex formulas or too many formulae on your object. Please refer to this link (https://resources.docs.salesforce.com/204/latest/en-us/sfdc/pdf/salesforce_formula_size_tipsheet.pdf)for additional information.