+ 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.

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 ];