0

I have a Lookup in my custom object to a Contact object exposed in Visualforce. The user selects a contact by doing a lookup:

<apex:page standardController="Software_Activation__c" extensions="SoftwareActivationController">
    ...
    <apex:inputField id="contact" value="{!Software_Activation__c.Contact__c}"/>
    ...
</apex:page>

I need to do some AJAX with the Email of this Contact so I need to expose the contact's email address in HTML somehow. I tried this:

<apex:inputText value="{!Software_Activation__c.Contact__c.Email}" id="shipToEmail" disabled="true" />

However, it didn't work:

Error: Unknown property 'String.Email'

How can I expose a lookup field's property in my HTML?

1 Answer 1

1

See Contact__c is actually just the id field, i.e. it will contain the Id of the Contact and not the actual Contact. Instead, what you want to do is use the reference field Contact__r, i.e. Software_Activation__c.Contact__r.Email to get the value of the referenced Contact.

Edit: Here you can find a detailed explanation from salesforce: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_and_custom_objects.htm

3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .