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
Peter Russell 9Peter Russell 9 

What object holds an opportunity's activity log?

I'd like to post activity to opportunities via API - what object sto
res the activity log?
Thanks in advance!
Deepali KulshresthaDeepali Kulshrestha
Hi Peter,

When an activity is created on the opportunity it stores that activity in two objects:
1- Task object: If you create a task or log a call or send an email through the activity section then it stores these records in the task object.
2- Event object: If you create an event then it stores in the event object.

you can query the activity of opportunity with the help of query given below:
List<Task> OpportunitytaskList = [Select Id, Subject, RecurrenceInterval, Status, 
                                          Priority,ActivityDate, WhoId, IsRecurrence, Description, 
                                          CallType,  CallDisposition, CallObject, CallDurationInSeconds, 
                                          IsReminderSet,RecurrenceRegeneratedType,
                                          TaskSubtype, Who.Name,IsClosed
                                          From Task 
                                          WHERE WhatId IN: opportunityIdSet
                                          ORDER BY ActivityDate DESC
                                          LIMIT 50000];
List<Event> OpportunityEventList = [SELECT Id, WhatId, StartDateTime, Subject, Type, 
                                           What.Name,
                                           EndDateTime, IsAllDayEvent, EventSubtype, ActivityDate,
                                           Description, DurationInMinutes, Location,
                                           IsPrivate, IsReminderSet, IsRecurrence2, ShowAs, 
                                           ActivityDateTime 
                                           FROM Event
                                           WHERE WhatId IN: opportunityIdSet
                                           ORDER BY ActivityDate DESC
                                           LIMIT 50000];
Hope this helps.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha.