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
mmcconnammcconna 

ActivityHistory SOQL relationship query help?

hi, bit of a problem with ActivityHistory

Documentation on ActivityHistory states:

Issue a SOQL relationship query with a main clause that references the object, and an inner clause that references the activity history, for example:
SELECT (SELECT ActivityDate, Description from ActivityHistory) FROM Account WHERE Id = '" + accId + "'"

When I issue this call from within my app:
SELECT (SELECT ActivityDate, Description from ActivityHistory) FROM Account WHERE Id = '00120000002dYd4'

the API returns me this error:
INVALID_TYPE: Didn't understand relationship 'ActivityHistory' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

So either the documentation or the API is wrong? Anyone know the correct way to get a list of activity history entries as part of an SOQL relationship query?

Cheers,
Moray

SuperfellSuperfell
You always use the relationship name, not the target object name, i'll get the sample in the docs updated. try this.

SELECT (SELECT ActivityDate, Description from ActivityHistories) FROM Account WHERE Id = '00120000002dYd4'
mmcconnammcconna
Cheers, does the trick!
M.
shashvatshashvat

Hi

 

Can you guic\de me if I want to extract the field values of Activity history in your query, how would I do it?