1

I have a Visualforce page which has a Case object. It's pretty standard. However when I try to refer the ContactPhone by the code, using <apex:outputText value=" {!Case.ContactPhone}"></apex:outputText>, the editor throws an error saying:

Invalid field ContactPhone for sObject Case.

I want to create a button that can show a pdf of the Case Object. So I created a Visualforce Page and tried to create a button that relates to the VF Page. But I got stuck here. Could anybody tell me what should I do? How can I refer to this field? Thanks

1 Answer 1

2

You have to use: Contact.Phone

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

as ContactPhone is available from Contact, basically it behaves as a formula field taking value from the Contact record.

Again, if the Visualforce is using StandardController of Case it works fine

<apex:outputText >{!Case.ContactPhone}</apex:outputText>
2
  • Thx Santanu, but I am using StandardController rit now <apex:page standardController="Case" renderAs="pdf" showHeader="false" applyhtmltag="false" > but <apex:outputText >{!Case.ContactPhone}</apex:outputText> doesn't work on me.
    – Barry Wang
    Commented Jan 25, 2017 at 22:00
  • Plus, do you 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 codes are: <apex:outputText value="{!Case.Contact}" /> and <apex:outputText value="{!Case.Account}" /> just like Case Owner. Thanks very much
    – Barry Wang
    Commented Jan 25, 2017 at 22:09

You must log in to answer this question.

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