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
keshava65keshava65 

case related Activity History

Hi all,
 case object Activity History show to account page at InlineVisualforce page
Best Answer chosen by keshava65
Prem Anandh 1Prem Anandh 1
Hi Keshava,

I have created a Inline VF page on Account detail page which will pull the related Case records Activity. Please refer below code:

VF Page Code:
 
<apex:page standardController="Account" extensions="CaseActivityController">
    <apex:pageBlock>
        <apex:pageBlockTable value="{!lstTask}" var="activity">
            <apex:column value="{!activity.WhatId}" />
            <apex:column value="{!activity.Subject}" />
            <apex:column value="{!activity.Status}" />
            <apex:column value="{!activity.CallType}" />
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

Controller Code:
 
public with sharing class CaseActivityController {
    
    public List<Task> lstTask  {get;set;}
    
    public CaseActivityController(ApexPages.StandardController std) 
    {
        Id AccountId = std.getId(); //Get AccountId
        
        //Query on Case
        Map<Id, Case> mapIdToCase = new Map<Id,Case>([Select Id from Case where AccountId =: AccountId]);
        
        //Query on Case Activity 
        lstTask = new List<Task>([SELECT CallType,Status,Subject,WhatId FROM Task where WhatId IN: mapIdToCase.keySet()]);
        
    }

}


Inline VF page on Account

This will return only Task records. If you want to pull Event records please write code for the Event. 


Thanks, 
Prem Anandh