Assume we have ObjectA__c with Field1__c and ObjectB__c with formula field Field2__c which is formula to ObjectA__r.Field1__c.

I expected change of record field Field1__c of ObjectA__c would cause trigger on ObjectB__c to fire with changed Field2__c field, but this doesn't happen.

Can anyone explain why? Alternatively, can anyone share link to docs where is behavior is explained?

  • Solution is to trigger from your other object and verify if your logic needs to be executed. – Samuel De Rycke Feb 19 '14 at 15:33

Basically, formula doesn't store any value. Formula is executed only when you retrieve it - use show this field on VF page or use formula field for your calculations in Apex code.

A formula is similar to an equation that is executed at run time.

An Introduction to Formulas

  • If you want to trigger some calculations for all objects which will be affected by changing field of ObjectA, I assume it will be needed to implement some complex logic. If you can tell us what exactly you want to achieve, maybe we might help you with it. – Andrii Muzychuk Feb 19 '14 at 12:26
  • My question was why it doesn't fire trigger. So, if a value of equation is changed then this should fire trigger on object where this value has been changed. Mentioned docs link just describes formula usage, however, unfortunately, doesn't contain answer to my question. – Patlatus Feb 19 '14 at 12:52
  • 4
    I believe it does answer your question. The reason it doesn't fire is because the value is not stored. It is merely calculated at runtime. If the value isn't stored, then there is no DML operation to change it. Triggers only fire on DML operations. – Chris Duncombe Feb 19 '14 at 12:58

I believe the value of a formula field is not stored in the database, and does thus not change as you would expected.

The formula itself it stored, and when the field is queried, the formula is executed to calculate the formula value, which is then returned or displayed.

  • 2
    this is my understanding as well, but couldnt find documentation as such. Still looking – Chris Duncombe Feb 19 '14 at 11:39
  • Never Mind, looks like @Chiz found it. – Chris Duncombe Feb 19 '14 at 11:40

Your Answer

