I am trying to query for others' Tasks within a trigger. (That is, retrieve Tasks whose OwnerId is other than the running user). I've reduced my query to the following:
Task anyTasks = [SELECT Id, OwnerId, Subject, ActivityDate FROM Task LIMIT 10 ALL ROWS];
This query is returning 0 rows. Even though I know there are plenty of open, recent tasks owned by others in this tenant.
This is a trigger, so there's way to specify "Without Sharing".
Is it not possible to query for tasks owned by others within a trigger, or am I missing something in my query?
Update: The problem is not Sharing, it's related to the fact that the running user is a Customer Portal userid. That userid, when executing Apex code, can insert Tasks records, but apparently cannot query [SELECT] those records. I am surprised, as this userid seems to have system-level permissions in Apex code - even having access to other objects that are not specifically permitted to a Portal or that profile. The Task object behavior seems unique.