There is an implementation restriction on Activity History (or Open Activities). When you query the relationship, security evaluation is implemented for users who don't have administrator permissions, and only a single parent record may be evaluated.
This error occurs because of the way Salesforce restricts the usage of Activities to users who do not have the View All Data permission. The restrictions are as follows:
- In the main clause of the relationship query, you can reference only one record. For example, you can’t filter on all records where the account name starts with “A.” Instead, you must reference a single account record.
- In the inner clause of the query, you can’t use WHERE.
- In the inner clause of the query, you must specify a limit of 500 or fewer on the number of rows that are returned in the list.
- In the inner clause of the query, you must sort on ActivityDate in ascending order and LastModifiedDate in descending order. You can optionally display nulls last. For example:
ORDER BY ActivityDate ASC NULLS LAST, LastModifiedDate DESC.
WHAT TO DO
There are two workarounds:
- Give the users who need to see Activity History or Open Activities in the View all Data permission in their profile. See more here.
- Change all references to Activities to Task and/or Events. You can do this by removing Activity History and Open Activities from related list and related column and add Tasks and Event instead.