Let's assume I have two Objects, Object A and Object B. Object A has two fields:

Field 1: Text field
Field 2: Lookup(Object B) 

I would like to create a Visualforce page that I can embed into the Detail layout of Object B, that will display a list of Object A > Field 1 from all the records of Object A that are referencing the record of Object B being viewed.

Seems this should be possible, hoping someone can point me in the right direction. I believe this is different from simply printing out the related list, because I would like to do some custom display handling of the print out.

Also, what is the proper terminology to refer to the "looked up" records?


1 Answer 1


Its called traversing the relationships.

you can simply use an output field on the VF Page so long as the Lookup is FROM the object the page is in TO the related object.

Say you have a field on the Opportunity named FieldA__c that looks up to objectA__c which has Field_ObjA__c.

In the vf Page (if properly set up) you can simply

<apex:outPutField value="{!Opportunity.FieldA__r.Field_ObjA__c"/>

If, however your question is the reverse where an Object Looks up TO the Opportunity then you will have to use code to gather the related records and then display then on the inline page

  • Eric, using the objects in your example, my question is how to display one or more fields from the Opportunity object on the ObjectA detail page for all the opportunity records that reference the record you are looking at. Nov 16, 2015 at 20:48
  • @mpaler - That would be the last paragraph. You will need to query for the records, then iterate over them to display on the page using a pageblocktable or some other VF iterable.
    – Eric
    Nov 16, 2015 at 21:01

You must log in to answer this question.

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