+ Start a Discussion
cpo87cpo87 

VisualForce Inline Component for Adding Contact Info To Tasks

I am trying to add contact information such as title, phone, and email to tasks.  I have tried to do this through a VisualForce page and I am meeting limited results.  The code below works up to a point.
 
Code:
<apex:page standardController="Task">
  <apex:pageblock title="Contact Details">
    <apex:pageBlockTable value="{!task.who}" var="tc">
      <apex:column headerValue="Task Contact Name" value="{!tc.name}"/>
      <apex:column headerValue="Task Contact ID" value="{!tc.id}"/>
    </apex:pageBlockTable>    
  </apex:pageblock>
</apex:page>

 
I don't seem to be able to access the email, phone, and title fields.  I have reviewed my Enterprise WSDL and I am unsure where I am pulling the information from for the name and id fields because if they were on the contact record then I should be able to pull other contact fields.
 
Any help is appreciated.
Ron HessRon Hess
You may need a extension controller to pull added info from the id of the who, that controller can make a query to get all those fields
cpo87cpo87

Ron,

Thank you for the help, one more quick question.  I seem to have no problem creating a custom contoller in my developer account or my sandbox but I don't seem to be able to do this in my production org.  The "quick fix" doesn't seem to come up and there is no "New"  button for creating apex classes.  Am I missing something here?

Thanks.



Message Edited by cpo87 on 07-17-2008 02:25 PM
Ron HessRon Hess
you cannot create Apex in a production org, rather you deploy it.

To get a controller into a production org, you must deploy the Apex code with proper testmethod code coverage.  Please read up on test methods in Apex  and deploy procedures, normally you can use Eclipse to deploy a working apex class from dev or sandbox into production.


cpo87cpo87
Ron,

I have been unsuccessful in creating this controller extension.  I don't quite understand how this extension allows me to access the information in the who record.  Here is my extension code.

Code:
public class ActivityContactExtension{

  private final Task who;
    
  public ActivityContactExtension(ApexPages.StandardController stdController){
    this.who = (Task)stdController.getRecord();
  }
  
  public String getGreeting() {
    return 'Hello ' + who + ' (' + who.id + ')';
  }  
}

 Here is my visualforce markup


Code:
<apex:page standardController="Task" extensions="ActivityContactExtension">
  {!greeting} <p/>
  <apex:pageblock title="Contact Details">
    <apex:pageBlockTable value="{!task.who}" var="tc">
      <apex:column headerValue="Task Contact Name" value="{!tc.name}"/>
      <apex:column headerValue="Task Contact ID" value="{!tc.id}"/>
    </apex:pageBlockTable>    
  </apex:pageblock>
</apex:page>

 And here is what "who" outputs - Task:{WhoId=0036000000KPqSJAA1, Id=00T6000000QxVJOEA3}.

How do I use my extension to access the contact information?  I think I am obviously struggling to understand how this extension actually helps me access the contacts title, phone, and email.  Is there any graphical representation of how all these elements work together?