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
Giancarlo AmatiGiancarlo Amati 

Access Account Activity history

Dear All,
I am starting a new project where I would need to access the "Activity History" which is an object accessible from the Account record. I was thinking to create either an APEX class or an Apex Trigger, to be able to access the history and retrieve the information I need. 

Is it possible with Apex to access those objects/records related to the Account record?

Is that the right approach? Is there a quicker way? 

Thank you for your help.
GC


User-added image
Pradeep SinghPradeep Singh
Hi, You cannot query directly but you can query by using relationship query:-
below is the example
List<Account> AccList = [SELECT Id,name,(SELECT Id, AccountId, WhoId, WhatId, Subject, IsTask, ActivityDate, OwnerId, Status, Priority,  IsHighPriority, ActivityType, IsClosed, IsAllDayEvent, DurationInMinutes FROM ActivityHistories) FROM Account ];