You need to sign in to do that
Don't have an account?
![Renee Ellis Renee Ellis](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Show related records of a custom object on a detail page for that custom object
Hi
I have a custom object with a master detail relationship to the Contact object.
I would like to have, on the custom object's record detail page, a list of all other records for that custom object's record that are related to the linked contact.
Like a related list, but for records on the same object, not a child object.
I found a way to show a related list for another object linked to the contact, but not on the same object
<apex:page standardcontroller="app__c">
<apex:relatedList subject="{!app__c.Contact__c}" list="apps"/>
</apex:page>
Org is still in Classic
VF code:- Exentsion :-
Hope this works.
Below Code can fulfill your requirements, Hope this will work for you.
Vf page :
<apex:page standardController="app__c" extensions="ShowRelatedrecord">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!appLst}" var="app">
<apex:column value="{!app.name}"/>
</apex:pageblockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Class :
public with sharing class ShowRelatedrecord {
public list<app__c> appLst{get;set;}
public ShowRelatedrecord(ApexPages.StandardController controller) {
appLst = new list<app__c>();
appLst = [Select id, name from app__c where Contact__c =: ApexPages.currentPage().getParameters().get('id')];
}
}
Please mark this as best answer if this solves your problem.
Thank you,
Ajay Dubedi
Hi Ashishk, unfortunately that solution didn't work, I go errors on line 5 of the extension.
Hi Ajay, thank you, that solution provided the block with table containing header. However no records listed.
any ideas?