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
MotokiMotoki 

How to display Contact Name field on Visual Force page?

Dear All,

 

I just started learning Apex and Visualforce page and i'm trying to make a simple form that send the Salutation, First Name and Last Name and save it in the Contact object.

 

However, i don't understand how to display the Contact.Name field like the edit Contact page under the Contacts tab where you have a Salutation dropdown list, First Name input field and a Last Name input field.

 

Could somebody be so kind to give me an example please?

 

Thank you very much for your advice.

 

Best Regards,

Motoki

Best Answer chosen by Admin (Salesforce Developers) 

All Answers

SteveBowerSteveBower
This was selected as the best answer
MotokiMotoki

Thanks mate, this documentation might have what i need. 

MotokiMotoki

How do you handle the Address Type for visual force page? For example, how do you split the Account.BillingAddress type into, street1, street2, suburb, state, postcode etc? 

 

Many thanks.

Motoki

MotokiMotoki

 


SteveBower wrote:

http://www.salesforce.com/us/developer/docs/cookbook/index.htm   look for visualforce.


 

Hi Steve,

 

I tried one of the example on this cookbook:

 

public class mySecondController {

  public Account getAccount() {
    return [select id, name,
            (select id, firstname, lastname
             from Contacts limit 5)
            from Account where id =
             :System.currentPageReference()
             .getParameters().get('id')];
  }
}
<apex:page controller="mySecondController" tabStyle="Account">
  <apex:pageBlock title="Hello {!$User.FirstName}!">
    You belong to the {!account.name} account.
  </apex:pageBlock>
  <apex:pageBlock title="Contacts">
    <apex:dataTable value="{!account.Contacts}"
                    var="contact"
                    cellPadding="4" border="1">
      <apex:column >
        {!contact.FirstName}
      </apex:column>
      <apex:column >
        {!contact.LastName}
      </apex:column>
    </apex:dataTable>
  </apex:pageBlock>
</apex:page>

 

 

But it gives me the System.QueryException: List has no rows for assignment to SObject class.mySecondController.getAccount: line 3, column 16 External entry point exception...

 

I don't understand why it has no rows, i have some contacts and accounts created in my org... Any ideas please?

 

Thank you very much for your advice

Best Regards,

Motoki

MotokiMotoki

Nevermind, i have found the reason and fixed it. thanks!

ishchopraishchopra

Hi,

 

Can you please tell me what changes did you make to sort out the error?

 

I am quite new to the VF and Apex

 


ish

Akash Diwan.ax1657Akash Diwan.ax1657

What was the error? & how did you fix it?