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
Gourav JainGourav Jain 

Using Standardcontroller Account ,how can i get the contact records?

Using Standardcontroller Account ,how can i get the contact records?

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

you can fetch contacts associated with a account using their relationship (master-child).

 

<apex:page standardController="account" >

 

    <apex:form >

        <apex:pageBlock title="Contact details for account" >

            <apex:pageBlockTable value="{!account.contacts}" var="con">

            <apex:column value="{!con.name}"/>

            <apex:column breakBefore="{!con.id}"/>

            </apex:pageBlockTable>

        </apex:pageBlock>

    </apex:form>

</apex:page>

 Make sure you enter account id in the browser.

for ex

 https://c.ap1.visual.force.com/apex/contactdetails?id=00190000003OHIS

 

where 00190000003OHIS is the id of account.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

you can fetch contacts associated with a account using their relationship (master-child).

 

<apex:page standardController="account" >

 

    <apex:form >

        <apex:pageBlock title="Contact details for account" >

            <apex:pageBlockTable value="{!account.contacts}" var="con">

            <apex:column value="{!con.name}"/>

            <apex:column breakBefore="{!con.id}"/>

            </apex:pageBlockTable>

        </apex:pageBlock>

    </apex:form>

</apex:page>

 Make sure you enter account id in the browser.

for ex

 https://c.ap1.visual.force.com/apex/contactdetails?id=00190000003OHIS

 

where 00190000003OHIS is the id of account.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

This was selected as the best answer
Yolanda Chase 8Yolanda Chase 8
How do I create a visualforce page showing contact information?