2

When you have a master-detail chain of objects several levels deep, sometimes a lookup field to the root object on each child object is helpful for easy navigation or to show deeper records than the immediate child records as a root object related list.

It is a while since I set something like this up, and in the past have had to do it via triggers because it is not possible to create a formula field of type "Lookup Relationship".

Has anything changed in the platform to make solving this problem easier e.g. declarative rather than code?

3
  • personally, i'd do this in a domain class for each child object as it avoids any recursion from a PB (plus you'll end up with testmethods). But PB should work
    – cropredy
    Sep 22, 2019 at 23:58
  • Thanks @cropredy. Do you mean that the domain class writes the lookup or that you use the domain class to navigate up and down the relationships? I want to be able to show e.g. the grand-child objects as a related list using layout UI, so need fields too.
    – Keith C
    Sep 23, 2019 at 7:28
  • Domain class writes the lookups.
    – cropredy
    Sep 23, 2019 at 13:00

1 Answer 1

1

I've not tried it but this should be possible with Process Builder/Flow (on the child objects). Those do especially support cross-object formulas while workflow field updates don't.

Reparenting on an intermediate level may still require some sophistication (e.g. in a hierarchy Level_0__c <-- Level_1__c <-- Level_2__c, if you have a lookup from Level_2__c to Level_0__c and allow reparenting of a Level_1__c record to a different Level_0__c record - how do you update the lookups from all Level_2__c children of that Level_1__c record to the new Level_0__c record).

You must log in to answer this question.

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