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

Displaying account related to contact in same vf page when contact id is given

do help me.



You can Use <apex:relatedList list="Account" /> just need to provied the Id of the Account.

I think this will work.


Thanks and Regards



No this wont work,Account is not a related list of contact.


do reply for working solution.

Rahul SharmaRahul Sharma

Hi Alok,

You can query on Contact with Contact id and collect information of Account as well as Contact. since Account is in lookup relationship.


List<Contact> objCon = [Select Id, LastName, Account.Name, Account.Id from Contact where Id : ContactId];

Now in the page you can access objCon.Account.Name same like you do for objCon.LastName.


But rahul..


That i have to show thse details in visual force page...and contact id  have to pass trough url


and corresponding to that contact .i need to display related account on same visual force page.


what could be d soultion..

Rahul SharmaRahul Sharma

Create a page with Standard controller as contact and define a extension for it.

In the Extension's constructor  you will be getting the Id of the Contact which you are passing as parameter to your page.

Then query the information of contact and its parent account  in Object in the constructor, as discussed in my earlier post.

and use that object in your visualforce page.