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
Mathew Andresen 5Mathew Andresen 5 

Contact address not displaying in visualforce page

Hi,

I'm just starting to build my page, but I'm having some trouble getting a contact's address to display (other contact info displays fine).

I get the error  "Unsupported type common.api.soap.wsdl.Address encountered"

Thanks,
 
<apex:page controller="ContractClass">
    
    <apex:pageBlock title="Client Information">
    <apex:pageblocksection columns="2">
		<apex:outputText label = "Contact Name" value="{!Contact.FirstName}  {!Contact.LastName}"/> 
        <apex:outputText label = "License Company" value="{!Opportunity.Account.Name}"/>
        <apex:outputText label="Mailing Address"  value="{!Contact.MailingAddress}"/>
   
       </apex:pageblocksection> 
	</apex:pageBlock>        
</apex:page>

public class ContractClass {
    Contact oppContact = new Contact();
    Opportunity myOpp = new Opportunity();
    String oppId;
    String acctId;
    
    
    public ContractClass() {
        oppId = '006R0000008fsEY';
        myOpp = [SELECT Id, Amount, Account.Name, Account.Id FROM Opportunity WHERE Id = :oppId LIMIT 1];
        acctId = myOpp.Account.Id;
        oppContact = [SELECT FirstName, LastName, MailingAddress FROM Contact WHERE accountId = :acctId LIMIT 1];
        
    }
    
    public Opportunity getOpportunity() {
        return myOpp;
       
    }
    
    public Contact getContact() {
        return oppContact;
    }
    
}
Best Answer chosen by Mathew Andresen 5
harsha__charsha__c
Mailing Address is a combination of 5 fields (MailingCity, MailingStreet, MailingState, MailingPostalcode & MailingCountry). You need to query & use these fields to display Contact's Address in the vf page.

The MailingAddress field of Contact can not be used as a field when it comes to the API as far as I knew. The same is for Billing/Mailing Address on Account.

Hope this helps..

- Harsha

All Answers

KevinPKevinP
Instead of using an outputText tag, which expects a String data type, use the 
 
<apex:OutputField value="{!Contact.address}" />
Output Field as a tag, is capable of handling any sobject or type.
 
harsha__charsha__c
Mailing Address is a combination of 5 fields (MailingCity, MailingStreet, MailingState, MailingPostalcode & MailingCountry). You need to query & use these fields to display Contact's Address in the vf page.

The MailingAddress field of Contact can not be used as a field when it comes to the API as far as I knew. The same is for Billing/Mailing Address on Account.

Hope this helps..

- Harsha
This was selected as the best answer
Mathew Andresen 5Mathew Andresen 5
<apex:OutputField value="{!Contact.MailingAddress}" />

Doesn't seem to work, I get the error "Unsupported type MailingAddress encountered."

{!Contact.MailingCity} etc does work, I will just use that.

Thanks,
kuldeep paliwalkuldeep paliwal
Controller:--
[select  MailingStreet, MailingCity, MailingState, MailingPostalCode, MailingCountry from contact]
VfPage:---
   <apex:inputField value="{!row.theAccount.MailingStreet}"/>
            <apex:inputField value="{!row.theAccount.MailingCity}"/>
            <apex:inputField value="{!row.theAccount.MailingState}"/>
            <apex:inputField value="{!row.theAccount.MailingPostalCode}"/>
            <apex:inputField value="{!row.theAccount.MailingCountry}"/>