We have a Site Collection with several Team Sites. Each Team site has a task list.
We would like to show an aggregated list of tasks in all team sites on the root site. What is the best way to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use SPSiteDataQuery to query all lists across all webs of a collection. You can query for a specific type of list by passing a ServerTemplate value to the SPSiteDataQuery.Lists property. The ServerTemplate ID for Tasks is 107. Querying all webs is accomplished by passing the “SiteCollection” value to the SPSiteDataQuery.Webs property.
SPSiteDataQuery returns a DataTable with very limited information (only list and item IDs I think) so you have to specify all extra fields in the SPSiteDataQuery.ViewFields property.
The following code (adapted from the class documentation sample) will return all Tasks in progress, order by their start date descending: