0

I know they are quite a few questions regarding formula being to long (over 5000 characters), from my understanding if the formula uses fields who are also part of other formula fields this will count towards the limit right?

But how come i get the following error message, when using this formula field?

IF(
    DATEVALUE( CreatedDate ) > DATE(2020,1,1), 
    1.2, 
    1
)

Formula field error

3

As the error says, "formulas that reference this field are no longer valid." Formulas that reference other formulas end up being the size of the dependent formulas plus their own size every time they are referenced, which can cause this problem.

For example, let's say that your formula was simply:

Created_Date_Example__c

BLANKVALUE(CreatedDate, DATE(2000,1,1))

Then you write a second formula, such as:

Dependent_Formula__c

IF(Created_Date_Example__c < DATE(1999,1,1),
  "Earlier than 1999",
  IF(Created_Date_Example__c < DATE(2000, 1, 1)
    "Earlier than 2000",
    "Later than 2000"
  )
)

Then, the second formula uses the computed size of the first formula twice. Obviously, this would still compile, but if you later made Created_Date_Example__c more complicated:

IF(OR(CreatedDate=NULL, CreatedDate<DATE(2000,1,1)), DATE(2000,1,1), CreatedDate)

Then the second formula's size would increase as well, even though you're not editing it. Obviously, this example still compiles, but it's rather easy to go over the maximum size in a dependent formula if you do this.

You'll need to try and optimize your other formulas, or you won't be able to make any further changes to this one, unless the result is smaller than before. I doubt you can optimize this formula to a smaller size, so you'll need to review the other ones.

Alternatively, you might create a new numeric field, and use a Workflow Field Update to set the value for this field. This eliminates the need for this formula field, which will reduce the size of the formulas that depend on it.

Also see Knowledge Article 000324937 that goes into more detail, and Tips for Reducing Formula Size.

Summary: this formula is used in other formulas, so their size is going over 5k characters compiled. You need to fix those formulas, instead.

4
  • If I understood correctly, is like the actual limit is more towards the object rather than the actual field, the field of course has its limit but if my object will contain several formula fields, it seems better based on this, to void creating formula fields and have actual fields calc by trigger or flows? as in this example there are no dependant fields on the formula I am trying to save – manza Feb 17 at 23:39
  • @manza It could be a formula on a completely separate object (cross object formulas). The error is specific; you're doing something that results in a formula elsewhere being oversized. The per-object limit, as I've been told, no longer applies (or maybe I misunderstood it to begin with). – sfdcfox Feb 17 at 23:49
  • 1
    to be honest I am extremely confused, as my formula is simple only use this DATEVALUE( CreatedDate ), and no other formulas are referencing this formula field, and as you can see this formula is not reference any other formulas, depending on the CreatedDate it through 1.2 or 1. Having say this, my object has 3 more formula fields that check CreatedDate and depending on this it return 1.4 or 1, but non of this formulas are reference between each other, they are not cross object nor "cross formulas in between", hopefully my explanation has sense – manza Feb 18 at 0:20
  • Great Answer @sfdcfox , Awesome Explanation – SFDC Feb 18 at 3:32

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.