Plumtree EDK (Enterprise Web Development Kit) 5.4.0 |

# ITaskListManager.QueryTasks Method (IProject, ITaskFilter)

Returns an array of `ITask` in the given project based on the `ITaskFilter`.

ITask[] QueryTasks(
IProject project,
ITaskFilter taskFilter
);

#### Parameters

project
  The project to query tasks from; cannot be `null`.
taskFilter
  The task filter to construct the query; cannot be `null`.

#### Return Value

An array of `ITask` objects in a project.

#### Remarks

The following sample code shows how query for tasks in a project.

    ITaskFilter taskFilter = tasklistManager.CreateTaskFilter();

    //search on all tasks; other options include searching for COMPLETED tasks, OVERDUE tasks, or PENDING tasks
    taskFilter.CompletionType = TaskCompletionFilterTypes.All;

    //limit the return results to be 10; setting this to 0 will return all results
    taskFilter.MaximumResults = 10;

    //disable security checking on the returned objects against the user who performs this query,
    //so that all objects will be returned
    taskFilter.RestoreSecurity = false;

    //user TaskQueryOrder to sort the query result; below TaskQueryOrder shows sorting the returned task lists by NAME in ascending order
    TaskQueryOrder taskQueryOrder = new TaskQueryOrder(TaskAttributes.Name, true);
    taskFilter.setQueryOrders(new TaskQueryOrder[] { taskQueryOrder } );

    //an array of ITask objects are returned from queryTasks(ITaskList); if no result is retrieved, a zero-length array will be returned
    ITask[] retrievedTasks = tasklistManager.queryTasks(project, taskFilter);

#### Exceptions

Exception Type | Condition
--- | ---
CollaborationException | The method call resulted in an error.
InvalidOperationException | The project has not yet been stored or has already been removed.
SoapException | There is a communication problem during the execution of the remote method call.

#### See Also

ITaskListManager Interface | Plumtree.Remote.PRC.Collaboration.Tasklist Namespace | ITaskListManager.QueryTasks Overload List