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
Ivan WinzerIvan Winzer 

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

So i have a case field i am trying to create to push a certain shipping rate to the contact field. My formula filed Shipping Cost reads as:
CASE(Shipping_Cost_Key__c, 
"CO2", 20, 
"CO4", 22,
"CO6", 10, 
"FL2", 20, 
"FL4", 26,
"FL6", 10,  
"GA2", 26, 
"GA4", 33,
"GA6", 10,  
"KS2", 25, 
"KS4", 30,
"KS6", 10,  
"MO2", 28, 
"MO4", 31,
"MO6", 10,  
"NC2", 29, 
"NC4", 31,
"NC6", 10,  
"NE2", 28, 
"NE4", 31,
"NE6", 10,  
"NM2", 24, 
"NM4", 27,
"NM6", 10,  
"NV2", 24, 
"NV4", 26,
"NV6", 10,  
"SC2", 29, 
"SC4", 32,
"SC6", 10,  
"TN2", 29, 
"TN4", 32,
"TN6", 10, 
"TX2", 28, 
"TX4", 32, 
"TX6", 10, 
0)

and is field it is looking at is Shipping Cost Key:
 
if(Club_Bottle_Count_2__c >0, OtherState+TEXT(2), 
if(Club_Bottle_Count_4__c >0, OtherState+TEXT(4), 
OtherState+TEXT(6)))
I keep getting Error: Compiled formula is too big to execute (8,512 characters). Maximum size is 5,000 characters.

Can anyone help me figure out how to get this to work.

Ivan
 
Alain CabonAlain Cabon
Hi,

For a so simple formula, there are not a lot of solutions.

With the process builder, each time the object is modified and the values of Club_Bottle_Count_2__c, Club_Bottle_Count_4__c  or OtherState changes, you have to update a stored value of Shipping Cost Key (it is not a formula anymore but a field text).

If Shipping Cost Key is not a formula anymore but a field text, the compiled size is 1,852 characters.

If this formula is only shown into a VFP, you can use the apex code but this field will be not known in report or SOQL requests anymore.

Regards
Ivan WinzerIvan Winzer
hi Alaln,

So I created a text field for the shipping cost key and building a WFR to push the data to the field but now im getting this error when trying to add a formula to the work flow:

Error: Formula result is data type (Text), incompatible with expected data type (true or false).

I pretty much took the code from the shipping cost key formula and am placing it in the workflow rule. Any idea on how to get it past this text error.

Ivan
Alain CabonAlain Cabon
Hi Ivan,

WFR uses field updates. Why don't you use the process builder?

Workflow Rule Migration: Say Goodbye to Workflow and Hello to Process Builder
Process Builder is the future.  
We’re no longer enhancing Workflow. We still support your use of workflow rules, and will continue to do so. But all new functionality for the workflow use case will come through Process Builder. If you want to use the shiny new functionality, migrate your automation to Process Builder. Now you have all the information you need to decide between Workflow and Process Builder for future projects.

https://trailhead.salesforce.com/fr/modules/workflow_migration/units/workflow_migration_intro

By the way, you have used a formula in your WFR for a condtion and not for the field update itself.
Use a formula to set the new value is avalaible for a fied update of text.

Regards