1

I have a formula that is far too big. My Picklist contains only two values 195mm or 215mm. If it's 215mm then I need to add 110 to the calculation. If it's 195mm then I need to add 101.

Currently it's at a massive 9000 characters. Might I need to create a workflow for Overall_Gap_div2_exact__c?

IF((ISPICKVAL(Louvre_Calculator__c, "215mm Louvre Calculator")),110 + ( Overall_Gap_div2_exact__c /2)- PCL__c, 101 + ( Overall_Gap_div2_exact__c /2)- PCL__c)
  • 6
    Could you elaborate what exactly you're asking about? My guess here is that Overall_Gap_div2_exact__c is another formula which is big enough that combined with the new one it hits the limits. You can overcome that issue in many ways depending on what formula is doing. One of the ways is creating apex trigger for the object which have that formula – user1974566 Jul 2 '18 at 6:59
  • 2
    You might also want to check out the Tips for Reducing Formula Size tip sheet - resources.docs.salesforce.com/214/latest/en-us/sfdc/pdf/… – shannonsans Jul 2 '18 at 17:13
2

You've got maybe, four options:

  1. Move any other formulas to workflow
  2. Move any other formulas to an apex trigger/batch class
  3. Reduce the number of references to external formulas in this formula
  4. Move this formula to workflow rule/trigger

Without seeing the details of the other fields in the formula (PCL__c, Overall_Gap_div2_exact__c) its hard to tell exactly where things should be moved. I'm guessing these are very large, complex formulas, since the actual formula in the question is rather small.

Since the second half of your IF results both do the same math, you can move the math outside of the formula, reducing the number of formula references in total.

Each field which results in a formula adds the full characters of all formulas they reference & themselves, so calling a field with a large size more than once gets very expensive. By removing half of our formula references, we should be able to drastically lower the size of the formula. About half of 9k is 4.5, so that should get you closer to the 5k limit.

(
    IF(
        ISPICKVAL(Louvre_Calculator__c, "215mm Louvre Calculator"),
        110,
        101
    ) 
    + (Overall_Gap_div2_exact__c / 2)
) - PCL__c

The returned number from the IF is used by the rest of the formula. Its determined, then we do some math on the result.


PS: Next time you ask about improving a formula, some schema information about the referenced fields would be useful. The raw formulas don't need to be included, but the size of each formula should be.

You can get the formula size by going to the page, clicking edit, and then under "Advanced formula editor", click "Check Syntax". It gives you a size in the output. Knowing the size of each field, and which fields are formulas would have improved the ability of myself & others to answer your question.

  • 2
    I think your answer could better highlight that the Overall_Gap_div2_exact__c and PCL__c fields are being double counted. That is the first, most obvious change and could well fix the issue on its own. – Adrian Larson Jul 2 '18 at 17:07
  • 2
    Agreed, edited. I left the options up front for OP's reference, but changed the focus of the answer. Kind of stumbled on it half way through the answer. If you have any further suggestions, feel free to comment or edit. – battery.cord Jul 2 '18 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.