If you are working with formula fields in salesforce then you might have seen this message :
“Compiled formula is too big to execute. Maximum size is 5,000 characters.”
This means that the query generated by your formula syntax is too big for the database to handle all at once. Formula size problems come in two flavors: the formula is too long, or its compiled size is too big.
If you are thinking to reduce the number of characters in your formula, it's not going to work. Comments, white space and field name length make no difference on the compile size.
If you are planning to break the formula into multiple formulas fields, that doesn't going to work either as the compile size of each field is included in the main formula’s compile size.
There could be multiple ways to get rid of this issue but the best one is to use a Workflow field update :
- Create a custom field of the type your field update formula will return, such as Date or Number. Don’t add it to any page layouts.
- Create a workflow rule on the object. Set it to execute whenever a record is created or updated.
- Create a Field Update workflow action. Choose the custom field you created in Step 1 as the target, and copy part of your large formula into the formula that sets the value in that field.
- In your formula field, replace the part of the formula you copied to the field update action with a reference to your custom field.
1 Comments
I recently published an app named Unleash Your Formula. https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3u00000MS8T1EAL
ReplyDeleteThe app does something simple, it copies and syncs formula fields to the specified non-formula field (of the same type). This is an effective way to handle character limits.
Most character limit issues arise because the formula is referencing another formula, often multiple times, and each additional reference increases the formula character size by the size of referenced formula field.
With this app, you can reference instead the mapped non formula field, which will quickly reduces the character limit.
Even if you indeed have 5000 characters in a single formula, you can split it up into multiple formulas and use the same trick.