function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AncaDAncaD 

Formula field to retrieve data from the latest record of a related object

I have a custom object (co1) that has a lookup field to another custom object (co2). The co1 object is a related list for another object (co3). I want to display in the related list for co1 a field from the newest record from co2 that is associated with co1.

 

Is it possible? Or do I need to create a regular field in the co1 object for the field from co2 and update it with the latest data from co2 in code?

 

 

Thank you for any suggestions 

mpannmpann

Generally, the answer is no. However, I've played with this a little bit and here is a workaround you might try. It only works if your objects are related through a master-detail relationship.

 

You can create a roll-up summary field on the master object that performs a MAX operation on all related child records' date field. This will return the date of the most recent date.

 

Is that what you were looking for?

 

AncaDAncaD

Unfortunately, I can't create a master-detail relationship between co1 and co2, with co2 as a child, because co2 is a parent in another master-detail relationship.

 

 

mpannmpann
In this case it is not possible through standard customization, as far as I know. You would be able to write a trigger, however, that would update the parent record with the date of the latest child.