I have two objects.

Work (Master Object) Field: Work Done Tasks (child object) Field: Work Done

I want to create a formula field on the master record Work so that when the last 3 records of the Child object Tasks field Done = True, it would set the field on the parent object to true.

How can I do this using a formula? or would I need to use scheduled Apex?

  • You could have a roll-up field on the parent counting the number of children with field Done = true. You could have a formula field on the Parent called Done which said that when this count of child "done" = 3 then the value of it is true. I'm not quite sure what you mean by "last 3 records" is this chronological or just that there must be 3?
    – Doug B
    Jun 15, 2016 at 15:55
  • It would be chronological order. so the last 3 records based on today data.
    – Jeremy W
    Jun 15, 2016 at 16:02
  • 2
    I think you'll probably need to use a trigger in order to fully cover your requirements. And consider whether they are the last three tasks based on created date or on modified date or on another date field from the task. Also what happens if all the tasks are complete but there are fewer than 3? It's probably going to be a lot easier and clearer to write this in a trigger and then you can write good tests for it.
    – Doug B
    Jun 15, 2016 at 16:09

1 Answer 1


It cannot be done by formula. You need to write apex code for this logic.

You must log in to answer this question.

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