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
BeginsfdcBeginsfdc 

Custom controller is unable to show the desired output in VF page

this post is closed

bob_buzzardbob_buzzard

I don't think that this query:

 

  List<Account> acc1List=[select (select Salutation,FirstName,LastName,Phone ,Email from Contacts where id =
   :accId) from Account];

 

is doing what you want.  This will retrieve a list of all accounts in the system, and populate the contact relationship if the contact id is equal to the accId.  I reckon you want to retrieve the single account that the contact is related to. Something like:

 

 

List<Contact> accList=[select Salutation,FirstName,LastName,Phone,Email,AccountId from Contact where id =
   :accId];
   if(null!=accList && accList.size()>0){
       contact = accList.get(0);  
       }
       List<Account> acc1List=[select (select Salutation,FirstName,LastName,Phone ,Email from Contacts where id =
   :accId) from Account where id=:contact.AccountId];

 Also, your naming is a bit confusing - you are using accId to hold a contact id and accList to hold a list of contacts.