Find your content:

Search form

You are here

Why do Queries on Tasks not return records when multi-connect is enabled?


I have a visualforce page and controller in a development org with multi-connect to tasks (shared activities) enabled. If I query a task with multiple connected contacts through that page it returns 0 rows and if I query it through the debug log the query correctly returns 1 row.


public class QueryController {

 public Integer count {get; set;}

 public QueryController()
     count = 0;
     ID taskid = ApexPages.currentPage().getParameters().get('id');
     list<Task> tasks = [select ID from Task where id = :taskid];
     count = tasks.size();


<apex:page controller="QueryController">
Query found {!count} tasks.

Attribution to: Greg Grinberg

Possible Suggestion/Solution #1

Have you used the debug logs or a heap dump to check that the ID is making it into the query correctly? The query should return the same values in the two different locations, so the fact that you get zero rows would suggest the ID isn't being merged into the query correctly.

Attribution to: Matt Lacey

Possible Suggestion/Solution #2

Updating the api version of the controller fixed the issue. It appears that queries from code that is saved with api version 23.0 or lower do not return Task records that use the multi-connect functionality. Since the debug log always runs with the latest api version it was returning the queries.

From the summer '12 release notes it is NOT a bug that multi-connect tasks are not visible from apex or the api in older api versions.

Attribution to: Greg Grinberg
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content