You need to sign in to do that
Don't have an account?
User One 35
How to display all child records in one place (Parent Object)
Display all Child Records on Parent Object
I want to display all child records on parent object here is my code
But it displaying only contact records, I want to display all records which related to the parent object (it means all child objects records should display in parent Account object) please help me how to use triggers here.
Apex Code:
public class ContactsRecordsToAccounts{
Public Id accID;
public List<Contact> contactList{get;set;}
public ContactsRecordsToAccounts(){
contactList = new List<Contact>();
accID= ApexPages.currentPage().getParameters().get('acId');
contactList = [SELECT FirstName,LastName,Email,Phone FROM Contact WHERE AccountID = : accID];
}
}
Visualforce Page Code:
<apex:page controller="ContactsRecordsToAccounts" sidebar="false" showHeader="false">
<apex:pageBlock >
<apex:pageBlockTable value="{!contactList}" var="con">
<apex:column value="{!con.FirstName}"/>
<apex:column value="{!con.LastName}"/>
<apex:column value="{!con.Phone}"/>
<apex:column value="{!con.Email}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
I want to display all child records on parent object here is my code
But it displaying only contact records, I want to display all records which related to the parent object (it means all child objects records should display in parent Account object) please help me how to use triggers here.
Apex Code:
public class ContactsRecordsToAccounts{
Public Id accID;
public List<Contact> contactList{get;set;}
public ContactsRecordsToAccounts(){
contactList = new List<Contact>();
accID= ApexPages.currentPage().getParameters().get('acId');
contactList = [SELECT FirstName,LastName,Email,Phone FROM Contact WHERE AccountID = : accID];
}
}
Visualforce Page Code:
<apex:page controller="ContactsRecordsToAccounts" sidebar="false" showHeader="false">
<apex:pageBlock >
<apex:pageBlockTable value="{!contactList}" var="con">
<apex:column value="{!con.FirstName}"/>
<apex:column value="{!con.LastName}"/>
<apex:column value="{!con.Phone}"/>
<apex:column value="{!con.Email}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
You have to query all the objects in the same way you did for contacts. And display them as did for Contacts. See my example code after adding opps.
Class: Visualforce Page:
Add all the fields you want to the query and also in Visualforce.
All Answers
You have to query all the objects in the same way you did for contacts. And display them as did for Contacts. See my example code after adding opps.
Class: Visualforce Page:
Add all the fields you want to the query and also in Visualforce.
Thanks for reply but I want to do with trigger please can you help me how to do with triggers
Thank you
If you dont want to use a controller you can directly display related lists in VF page. See example below. Please mark my response as correct answer if this helped you.