1

I used a VF Page and created a button that used this VF Page. Is anybody know why the value of Case Owner doesn't show correctly, my code is like this:

<apex:outputText value="{!Case.Owner}" />

The data type of this value is Lookup(User,Queue). Does it matter? And I meet the same situation with Contact Name and Account Name. Their markup I use is:

<apex:outputText value="{!Case.Contact}" />
<apex:outputText value="{!Case.Account}" />

1 Answer 1

2

You have two problems:

  • You should use the <apex:outputField> component
  • The actual field API Names end with Id

Here is a simple demo page to illustrate how to display these fields properly:

<apex:page Standardcontroller="Case">
    <apex:pageBlock>
        <apex:pageBlockSection>
            <apex:outputField value="{!Case.OwnerId}" />
            <apex:outputField value="{!Case.ContactId}" />
            <apex:outputField value="{!Case.AccountId}" />
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

These fields are actually named OwnerId, ContactId, and AccountId, despite being displayed in the UI without that Id suffix. And the field itself simply holds the Id of the related object. The standard Page Layout UI and the <apex:outputField> component perform some magic to display a linked name instead, but that's not the underlying data structure.

You must log in to answer this question.

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