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
AnujaAnuja 

Problem while Diplaying contacts

Hi,

 

I want to display Contacts in visualforce page.

I am selecting an account through lookup field and after selcetion i want to display related contacts.

How should i do this?

 

Can anybody help.

 

Thanks,

Anuja

Best Answer chosen by Admin (Salesforce Developers) 
Bhawani SharmaBhawani Sharma

Hi Anuja,

 

You can get the result through the following code:

<apex:page standardController="Account">

<apex:detail subject="{!Account.Id}" />

<apex:relatedList list="Contacts" />

</apex:page>

 

make sure id of account record should be in request parameter.

like if page name is "Test" then URL should be  :

https://c.na8.visual.force.com/apex/Test?id=accountId

All Answers

Bhawani SharmaBhawani Sharma

Hi Anuja,

 

You can get the result through the following code:

<apex:page standardController="Account">

<apex:detail subject="{!Account.Id}" />

<apex:relatedList list="Contacts" />

</apex:page>

 

make sure id of account record should be in request parameter.

like if page name is "Test" then URL should be  :

https://c.na8.visual.force.com/apex/Test?id=accountId

This was selected as the best answer
AnujaAnuja

Hi,

 

Thanks for reply.

I am using account as a standard controller as i want to diplay list of accounts.

after selecting one account i wanted to display related contacts for that perticular account.

 

 

my VF page is -

 

<apex:page standardcontroller="contact">

<apex:form >
    <apex:pageBlock >
            <apex:outputText value="Account Name : " />
            <apex:inputField value="{!contact.accountid}"/>
    </apex:pageblock>      
</apex:form>

</apex:page>

 

 

Bhawani SharmaBhawani Sharma

I am not very much clear with your requirement, but as you said in the previous thread :

"I am using account as a standard controller as i want to diplay list of accounts.

after selecting one account i wanted to display related contacts for that perticular account."

 

if you want to dispaly the list of account , then you can use

 

 

<apex:page tabstyle="Account">
<apex:ListViews type="Account" />
</apex:page>

or

 you can get the advantage of StandardSetController :

 

 

<apex:page standardSetController="Account" recordSetVar="accounts" tabstyle="Account" >
<apex:pageBloackTable value="{!accounts}" var="item">
<apex:column value="item.Name" />
</apex:pageBlockTable>
</apex:page>