You need to sign in to do that
Don't have an account?
Amy Thropp
How to query activityhistory
I have a custom object that has related activities. I want to query events, current or in history, related to that custom object.
I can't seem to get around the error message that the activityhistory does support query.
Any suggestions on how to get around this? I know you can use activity history in a subquery, I just can't seem to get the syntax right.
I can't seem to get around the error message that the activityhistory does support query.
Any suggestions on how to get around this? I know you can use activity history in a subquery, I just can't seem to get the syntax right.
SELECT Subject FROM Event WHERE WhatId = '<Id of custom object record>'
select Name, (select activitydate, subject from activityhistories) from <Custom_Object__c> where id=
'<Id of custom object record>'
Amy try this nested query approach:
(you can alter nested SOQL to pull fields from your Activity Obj) as well can alter outer SOQL
*This pulls from Case as Parent
SELECT Id, (SELECT Id, Subject, CreatedDate FROM ActivityHistories WHERE CreatedDate = LAST_N_DAYS: 90) FROM Case WHERE Id != null AND Recordtype.Name='XYZ' order by lastmodifieddate DESC