2

I'm trying to sort a list of tasks by their due date in ascending order. I've looked in a couple of forums and none are what I exactly need. I'm sure this should be relatively easy but haven't found the way.

list <task> Tareas_abiertas  = [SELECT Id from Task where OwnerId =:usuario.id AND status='Open'];

My query is simple I just need to order it depending on due date. Help?

1 Answer 1

3

Try this -

list <task> Tareas_abiertas  = [SELECT Id from Task where OwnerId =:usuario.id AND status='Open' Order By ActivityDate];

And from this Salesforce help article you can see that the API name of Due Date is ActivityDate.

Also as suggested by @IllusiveBrian, here is the documentation on SOQL Order By - https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_orderby.htm#

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .