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

I am trying to grab the firstname, lastname and phone from the related list of contacts
Hey everyone, I am new to salesforce. 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
---------page--------
<apex:page controller="AccountController">
<div style="text-align: center:">
<p>Name:{!firstName}</p>
<p>Name:{!lastName}</p>
<p>Name:{!phone}</p>
</div>
</apex:page>
-------controller-------
public without sharing class AccountController {
public static string firstName;
public static string lastName;
public static string phone;
public case AccountController() {
string aId = ApexPages.currentPage(),getParameters().get('id')
List <opportunity> openList = [select id, FirstName, LastName, phone from contact where accountid = :aId ];
firstName = openList.FirstName
lastName = openList.LastName
phone = openList.phone
}
}
---Error---
I am getting an error 'AccountController.firstName'
Thank you in advance I really appreciate it!!
---------page--------
<apex:page controller="AccountController">
<div style="text-align: center:">
<p>Name:{!firstName}</p>
<p>Name:{!lastName}</p>
<p>Name:{!phone}</p>
</div>
</apex:page>
-------controller-------
public without sharing class AccountController {
public static string firstName;
public static string lastName;
public static string phone;
public case AccountController() {
string aId = ApexPages.currentPage(),getParameters().get('id')
List <opportunity> openList = [select id, FirstName, LastName, phone from contact where accountid = :aId ];
firstName = openList.FirstName
lastName = openList.LastName
phone = openList.phone
}
}
---Error---
I am getting an error 'AccountController.firstName'
Thank you in advance I really appreciate it!!
Try the code from
http://salesforcecodes.com/display-related-contacts-of-an-account-using-visualforce-page/
Related: https://www.forcetalks.com/salesforce-topic/how-to-display-names-of-contact-amp-opportunity-related-to-an-account-in-a-visualforce-page/
If this information helps, please mark the answer as best. Thank you
controller should be like:
I tried the solution on the page you recommended but I am getting 2 different errors
1:duplicate value found: unknown duplicates value on record with id
2:unknown value found: duplicate value on record with id:
--------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>
------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;
}
}