You need to sign in to do that
Don't have an account?
API User 189
Cannot query certain tasks
I am trying to programmatically reduce the number of tasks. I ran a simple query using in Apex Execute Anonymous:
To my confusion, the query came back with 0 results, even though I know for a fact that a task with that string in the subject exists. I then went to an actual Task with that in the subject and ran this query:
But that returned 0 results. I can manually edit and delete these tasks, but for some reason, I can't query them.
I did notice that the Tasks that were queriable have IDs that begin with 00T1 whilst these start off with 00TA. Is there anything to that? Are they recognized as a completely different object?
List<Task> tasks = [Select Id from Task WHERE Subject Like '%Was Email Sent%']; System.debug(tasks.size()); delete tasks;
To my confusion, the query came back with 0 results, even though I know for a fact that a task with that string in the subject exists. I then went to an actual Task with that in the subject and ran this query:
List<Task> tasks = [Select Id from Task WHERE Id = '00TA000002lcsWy']; System.debug(tasks); delete tasks;
But that returned 0 results. I can manually edit and delete these tasks, but for some reason, I can't query them.
I did notice that the Tasks that were queriable have IDs that begin with 00T1 whilst these start off with 00TA. Is there anything to that? Are they recognized as a completely different object?
You should query on Event object too.
If the problem still persists, Salesforce has an automatic arquiving rule to Task and Events. It is shown to you a number of objects in system's overview, but you can't find these records.
To solve it, you have to open a new case with Salesforce support.
Hope you find this solution useful. If it does, please mark as Best Answer to help others too.
Regards.