I usually create Formula Fields on Lookup relationships just for use in triggers. So I don't have to write a query to retrieve these fields and to simplify bulkification of triggers.

My question is, the values of the cross object formula fields are accurate in the Insert trigger? Because I have read somewhere that formula values are calculated asynchronously and if there are large number of records for the object then it may cause issue?

2 Answers 2


Roll-up fields are not accurate within a child's trigger context. They are calculated in Step 16 of the Triggers and Order of Execution, which is after all of the children have already gone through their validation, before DML triggers, and after DML triggers. You should not rely on these values ever being correct during the child's trigger phases.

  • Great. Is this (formula on Cross-Objects) good practice performance wise? OR should we use SOQL?
    – abdn
    Dec 15, 2016 at 16:41
  • 1
    @abdn It probably doesn't matter in the long run, but I personally prefer queries over formulas when you're talking about code, only because it's self-documenting. Once you start using formulas that way, you have to go over to the field's definition to figure out what it's doing when something goes wrong. I'd usually consider using a formula only if I were already nearing my SOQL limit and I needed to optimize a bit.
    – sfdcfox
    Dec 15, 2016 at 16:45

So far as I know, this applies to Roll-Up formulas, other formulas are calculated when they are called

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .