You need to sign in to do that
Don't have an account?

I am trying to display all the phone, firstname, lastname number from related list of contact
Hey everyone, I am new to saleforce. I have a question I am trying to grab the firstname, lastname and phone from the related list of contacts and display it on a visualforce page but I have 2 errors
1:duplicate value found: duplicate value on record with id
2:unknown property AccountController.contacts
------------Apex class----------
public class AccountController {
public List<Contact> AccountSummaryController(){
List<Contact> conresults = [Select Id, FirstName, LastName,Title,Email from Contact where accountid='001Dn0000087GegIAE'];
return conresults;
}
}
----------visualforce page--------
<apex:page controller="AccountController">
<apex:form>
<apex:pageBlock title="Contacts List" id="contacts_list">
<apex:pageBlockTable value="{! contacts }" var="ct">
<apex:column value="{! ct.FirstName }"/>
<apex:column value="{! ct.LastName }"/>
<apex:column value="{! ct.Title }"/>
<apex:column value="{! ct.Email }"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Thank you in advance
1:duplicate value found: duplicate value on record with id
2:unknown property AccountController.contacts
------------Apex class----------
public class AccountController {
public List<Contact> AccountSummaryController(){
List<Contact> conresults = [Select Id, FirstName, LastName,Title,Email from Contact where accountid='001Dn0000087GegIAE'];
return conresults;
}
}
----------visualforce page--------
<apex:page controller="AccountController">
<apex:form>
<apex:pageBlock title="Contacts List" id="contacts_list">
<apex:pageBlockTable value="{! contacts }" var="ct">
<apex:column value="{! ct.FirstName }"/>
<apex:column value="{! ct.LastName }"/>
<apex:column value="{! ct.Title }"/>
<apex:column value="{! ct.Email }"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Thank you in advance
Refer the below link have solution for similar kind of ask.
https://salesforce.stackexchange.com/questions/295767/retrieve-account-related-contacts
If this helps, Please mark it as best answer.
Thanks!!