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
hideawayguyhideawayguy 

related object activity history

hi again, 

 

i'm in the very beginning stages of trying to get the activity history from a related object to display in a visual force page - very new to this as i'm sure you'll be able to tell...

 

i have this controller......

 

public class ContactController {

List<Contact> contact;

public List<Contact> getContact() {

if (contact == null) {
contact = [SELECT Id, Name, Email FROM Contact where Id =: '0035000000Zm8Zq'];
}
return contact;
}
}

 

and this vf page that calls it...

 

<apex:page controller="ContactController">

 

<apex:relatedList list="ActivityHistory" ></apex:relatedList>
</apex:page>

 

it displays nothing. i'm wondering if i'm even going about this in the right way? my assumption is that if i return the contact from the controller, i should be able to use the apex related list to display the activity history. 

 

any help/direction is greatly appreciated. 

 

Best Answer chosen by Admin (Salesforce Developers) 
Arun MKArun MK

Hi,

 

There is no need for a controller here. What you can do is create a VF Page (let the name be ContactActivityHistoryPage).

 

<apex:page standardController="Contact">

    <apex:relatedList list="ActivityHistories"/>

<apex:page>

 

And the URL to call this page should be somthing like this https://c.ap1.visual.force.com/apex/ContactActivityHistoryPage?id=contactId

 


Put yor contact Id in the id parameter of the url.

 

This page will display all the Activity Hostory related to the record.

 

Let me know, if this is what you want.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

 

Regards,

Arun

All Answers

Arun MKArun MK

Hi,

 

There is no need for a controller here. What you can do is create a VF Page (let the name be ContactActivityHistoryPage).

 

<apex:page standardController="Contact">

    <apex:relatedList list="ActivityHistories"/>

<apex:page>

 

And the URL to call this page should be somthing like this https://c.ap1.visual.force.com/apex/ContactActivityHistoryPage?id=contactId

 


Put yor contact Id in the id parameter of the url.

 

This page will display all the Activity Hostory related to the record.

 

Let me know, if this is what you want.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

 

Regards,

Arun

This was selected as the best answer
hideawayguyhideawayguy

thanks for the suggestion arun... i'll give that a shot as well. while we're on this topic though, i found another solution, albeit one that comes with issues...

 

so i'm on a custom object (booking) that has a lookup to contact. this code gives me what i want, with some exceptions....

 

<apex:page standardController="booking__c" showheader="false">

<apex:relatedList list="ActivityHistories" rendered="true" subject="{!booking__c.Contact_Lookup__c}"></apex:relatedList>
</apex:page>

 

that gives me the activity history that i'm looking for when i place it on the details page as a visualforce page. my problem is the buttons for send email, log a call, etc.. are still at the top of that list AND it's in an iframe or something. when a user clicks on a record, it takes them to an iframe version of salesforce. 

 

2 questions

 

1. do you know how to get rid of those buttons for just this instance of showing the activity history.

 

2. is there a way to make the page not submit the links in the iframe, but just submit the whole page ?

 

thanks again for the help...

 

dustin

BobBob

I tried this on my Case force.com site and the activity history is not showing up.

 

please see the code below. I just added the <apex:relatedList list="ActivityHistories"/> at the end of my code to try. Any suggestions would be greatly appreciated.

 

<apex:page standardcontroller="Case" showheader="false" sidebar="false" extensions="BL_CaseFileUpload">

<html>
<head>

<style>
    h1
    {
        color: red;
        font-size: 16px;
        font-family: Arial, Sans-Serif, Times New Roman;
        margin-bottom: 20px;
    }
    td(left:5px}
</style>
 </head>
 <body>
 
<apex:form id="partsCase" >

    <table width="400px">
    
    <tr>
         <th>Name</th>
            <td><apex:inputField required="true"   id="cas18_ilecell"    value="{!case.SuppliedName}"/></td>
        </tr>
        
        <tr>
         <th>Company</th>
            <td><apex:inputField required="false"  value="{!case.SuppliedCompany}"/></td>
        </tr>
        
        <tr>
            <th>Address</th>
            <td><apex:inputField required="true" value="{!case.Web_Street_Address_1__c}" /></td>
        </tr>
        <tr>
            <th>City</th>
            <td><apex:inputfield required="true" value="{!case.Web_City__c}" /></td>
        </tr>
        
         <tr>
            <th>Country</th>
            <td><apex:inputField required="true" value="{!case.Web_Country__c}" /></td>
        </tr>
        
        <tr>
            <th>State</th>
            <td><apex:inputField required="true" value="{!case.Web_State__c}" /></td>
        </tr>
        
        <tr>
            <th>Postal Code</th>
            <td><apex:inputField required="true" value="{!case.Web_Postal_Code__c}" /></td>
        </tr>
              
    
        <tr>
         <th>Email</th>
            <td><apex:inputField required="true" id="email" value="{!case.SuppliedEmail}"/></td>
        </tr>
        
                
        
        <tr>
         <th>Phone</th>
            <td><apex:inputField required="true"  value="{!case.SuppliedPhone}"/></td>
        </tr>
      
      
          <tr>
            <th>Subject</th>
            <td><apex:inputText required="true" value="{!case.Subject}"/></td>
        </tr>
        
        <tr>
            <th></th>
            <td><apex:inputHidden value="{!case.Origin}" id="hiddenField"/></td>
        </tr>
        
       
        
       </table>
      
       <table>
               <tr>
           
            <td><br />* Please give a brief description of your request<br/><apex:inputTextarea required="true" rows="5" cols="50" value="{!case.Description}"/></td></tr>
             
           <tr>
           
        </tr>
        
         </table>
         <table>
         <tr><td><br/><br/><h1>Credit Card Information</h1><br/><br/></td></tr>
         
          <tr>
            <th>* Name as it appears on the card</th></tr><tr>
            <td><apex:inputField required="true" value="{!case.Name_On_Credit_Card__c}"  /></td>
        </tr>
        
       
        
        <tr>
            <th>Credit Card Type</th></tr><tr>
            <td><apex:inputField required="true" value="{!case.Credit_Card_Type__c}" /></td>
        </tr>
         <tr>
            <th>Card Number</th></tr><tr>
            <td><apex:inputField required="true" value="{!case.Credit_Card_Number__c}" /></td>
        </tr>
        
        <tr>
            <th>Expiration Month</th></tr><tr>
            <td><apex:inputField required="true" value="{!case.Expiration_Month__c}" /></td>
       </tr><tr>
        
        <th>Expiration Year</th></tr><tr>
            <td><apex:inputField required="true" value="{!case.Expiration_Year__c}" /></td>
        </tr>
        
               
         </table>
         <table>
        
        <tr>
            <td><br/><br/><br/>Please add your attachment before clicking the submit button below.<br/>
       </td>
        </tr>        
      
    <tr>
            <td><br/><apex:inputFile style="width:100%" id="fileToUpload" value="{!fileBody}" filename="{!fileName}" /> <br/><br/>
            <apex:commandButton value="Submit Request" action="{!UploadFile}"/>  
       </td>
        </tr>
       
      </table>
    <script>
        document.getElementById('{!$Component.partsCase}').elements['{!$Component.hiddenField}'].value = 'Parts Support - Web';
       
      </script>
   
   </apex:form>
 
  </body>
   </html>
    <apex:relatedList list="ActivityHistories"/>
</apex:page>