You need to sign in to do that
Don't have an account?
Andrew Mattie
SOQL subquery now returning limited and unsorted data
I have a SOQL query that hasn't changed in a long time that look something like this:
Any ideas?
SELECT Lead.Id, Lead.Name (SELECT Task.Id, Task.ActivityDate FROM Lead.Tasks ORDER BY Task.ActivityDate DESC) FROM Lead WHERE Id = 'xxx'In the past, that has always returned the specified lead info as well as all tasks they have, or at least as many as the API allowed for, sorted by most-recent activity / due date. At some point recently, that query started returning up to 15 tasks that are completely unsorted. I don't care so much about the limited number of tasks being returned, but the seemingly broken sorting behavior is causing problems for us.
Any ideas?
Granted - this was using force.com explorer -- Are you getting your results back from some other means?
I also tried in the SOQL workbench;
All Answers
Hi Andrew,
Well, other than a missing comma, your SOQL query seems to work like you want it to.
IDK what appens if you don't have a due date (ActivityDate) -- it might not list them in the order created.
The problem I have is that the due dates DO exist in the tasks that come back. The query results just aren't sorted by those dates any more. If you run that query on arbitrary leads in your own data set, do you see the tasks from the subquery come back sorted by newest first?
Granted - this was using force.com explorer -- Are you getting your results back from some other means?
I also tried in the SOQL workbench;
Anyway, thank you again for your time and help. Problem solved.