Inconvenient User Tasks Web Part and how to make it display all tasks
Customization, Inconvenient SharePoint, SharePoint, SharePoint 2010, Tips & Tricks
The out of the box available User Tasks Web Part allows you to show tasks assigned to the current user. This Web Part is a great building block for end users since it doesn’t require any configuration whatsoever. All you have to do is to add it to a page and it will automatically display all tasks assigned to the current user. Unfortunately by default the User Tasks Web Part displays only tasks assigned to the current user located in tasks lists in the current Site.
The scenario
Imagine you’ve been given the assignment of creating an overview of tasks assigned to users. To make it user friendly all you want to display are the tasks for the user currently visiting the site. Although there are multiple projects where the tasks can be created you were asked to provide a single overview for the users.
Choices, choices, every time choices
Reading the first part of the requirement you might start considering using the out of the box available User Tasks Web Part, which displays a list of all tasks assigned to the current user. Each task has a link attached to it so that it’s easy for users to quickly see more information about a specific task. However, because of the last part of the requirement, you cannot really use the User Tasks Web Part: after all it displays tasks from the current site only. So what are the options?
Embrace the development
If you are a developer or a power-user you know that aggregating all tasks assigned to the current user isn’t that complicated. Depending on your experience and knowledge of the platform you might come up with a custom solution: either some using the SharePoint API or a Data View Web Part-like solution configured through SharePoint Designer.
While there is nothing wrong with any of those approaches there is an easier way to get things done, especially if all you need to do is to display tasks from all sites using the default User Experience.
Content Query Web Part almighty
Content Query Web Part (CQWP) is probably the best content aggregation solution available on the SharePoint platform. Thanks to its built-in caching mechanisms it’s very well performing and since the presentation of the aggregated data relies on XSLT you it is very flexible and can be used in virtually any situation.
The great thing about using the CQWP for this purpose is the ability of configuring it through the UI. Using the standard properties you can configure just the right query to retrieve tasks assigned to the current user. If you however would like to present the retrieved tasks similarly to the standard User Tasks Web Part, it would take quite some effort to achieve the same result.
There is yet another way to get things done without too much work.
Customization through configuration
While it might seem impossible at first, the User Tasks Web Part ships with a hidden gem that allows you to display all tasks assigned to the current user.
Let’s start with adding the User Tasks Web Part. By default it will display all tasks assigned to the current user, stored in tasks lists in the current Site.
Although there are is one more task assigned to the current user, stored in the Team 1 site, it is not being picked up by the User Tasks Web Part we have just added.
As mentioned before, the property that allows you to change the default behavior of the User Tasks Web Part is hidden and cannot be modified through the UI. So in order to make the User Tasks Web Part display all tasks, you need to export the Web Part and change the value in the .dwp file.
After you open the .dwp file in your favorite text editor, you have to add the following snippet just before the </WebPart> tag:
<QuerySiteCollection xmlns="http://schemas.microsoft.com/WebPart/v2/Aggregation">true</QuerySiteCollection>
Important: It is important to include the xmlns attribute. If you omit it, the setting won’t work and the User Tasks Web Part will display tasks from the current site only as it does by default.
Once you do that, save the file, move back to SharePoint, upload the .dwp file and add the imported User Tasks Web Part. You should see all tasks assigned to the current user being displayed in the overview:
And that’s it: from now on, no matter where in the Site Collection a task will be created and assigned to a user, it will be displayed on the overview that you have just created.
One more important thing to notice is, that although I’ve used SharePoint 2010 as sample for this article, exactly the same approach can be used with SharePoint 2007.
Summary
Out of the box SharePoint ships with the User Tasks Web Part which allows you to display tasks assigned to the current user. By default this Web Part shows only tasks stored in the current Site. If all you need to do is to modify the overview and include all tasks from all sites in the Site Collection, the best approach is to change the value of a hidden property of the User Tasks Web Part.


















November 10th, 2010 at 10:43 am
Damn! I should've known this before, could have saved me a lot of time! Do you also know if it's possible to change the column displayed in this web part?
November 10th, 2010 at 6:35 pm
Genius, I'd just been wondering how best to do that (and thinking CQWP)!
Now I just need to consider if there are multiple site collections…
November 11th, 2010 at 7:49 am
@Jasper: Unfortunately the query is hardcoded and the Web Part is sealed. What you could do though, is to inherit from the base class so that you will get the UI functionality and then write your own query.
November 11th, 2010 at 7:50 am
@Andy Burns: Unfortunately neither the User Tasks Web Part or the CQWP support multiple Site Collections. For that you would have to create something yourself. Preferably it would be based on search to perform well, but you might need some other mechanism is real-time data is a must.
November 17th, 2010 at 12:33 pm
@Waldeck – Yup, absolutely. If they want multiple site collections, I'm thinking search, and if it has to be realtime – I'm thinking event handlers and a central list somewhere.
Still, there's a good chance the User Tasks Web Part might be enough!
November 17th, 2010 at 12:36 pm
Sorry, as a random question, how did you find out about the QuerySiteCollection element?
November 17th, 2010 at 1:35 pm
@Andy Burns: Reflector. You might want to use the User Tasks Web Part if you want the tabular view. On the other there is little difference with using a custom Web Part with grid view which might give you some more flexibility.
November 18th, 2010 at 10:16 am
Great option indeed, too bad that it doesn't display tasks from the "Project Task" list definition..
December 7th, 2010 at 1:15 pm
hi, thanks for this, seems a lot easier than using content rollup and messing with the fields displayed.
If a user is part of a group, and the task is assigned to a group, will this task appear in an individual users task list?
Thanks
Ash
December 7th, 2010 at 1:31 pm
Hi, thanks for posting this :)
I was wondering if a task was assigned to a group (say Approvers), and in that group the members were an AD security group, would each member of that group see the task?
Thanks, Ash
December 7th, 2010 at 5:42 pm
@Asher: I'm not sure how SharePoint internally translates the Assigned To: Me value. The best way would be to test it.
January 25th, 2011 at 7:11 am
Asher, the answer is no unfortunately. I am sure there is a way of over-riding the query in a Content Query Web Part to return all tasks assigned to individual and groups but I haven't yet nailed it. There are a few leads here: http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010general/thread/51cb1d00-4fc1-4564-a68a-0c687ff55d98/ and here: http://the-north.com/sharepoint/post/2008/04/14/Embed-CAML-Queries-into-the-Content-Query-Webpart-Finding-Draft-Publishing-Content.aspx
that might help though.
February 11th, 2011 at 2:45 pm
Thank you sharing this tip.
Note you can use this tip with "Relevant Documents" webpart (UserDocsWebPart).
March 11th, 2011 at 2:18 pm
Anyone managed to "make" Users Tasks Web Part to show tasks assigned to groups?
March 17th, 2011 at 6:47 pm
It was great before, all the tasks cross the site collection displayed in it, but later something went wrong, the webpart didn't show anything at all even I had tasks… Removing the tag then it works again but only in current web scope..
please help, what could be possibably wrong with it?
May 18th, 2011 at 1:57 pm
Hi Waldek,
you're always one step ahead! Thanks!
Can I post your trick on my Italian blog?
May 18th, 2011 at 3:37 pm
@Barbara: Thanks! Sure and I would appreciate it if you included a link to this post as well.
May 19th, 2011 at 12:12 pm
Thanks and Yes, for sure… Done it!
June 28th, 2011 at 3:04 pm
Is it possible to get this to work for "Project Tasks" as well?
July 21st, 2011 at 5:05 pm
I added the QuerySiteCollection node to the dwp file and imported and added to my site. The webpart is not displaying anything. The out-of-the-box User Task wb shows the task in the current site. Any thoughts?
July 25th, 2011 at 3:02 pm
@Madhu: did you add the xmlns attribute as well? It won't work without it…
August 29th, 2011 at 9:09 pm
I get the following error:
An error has occurred.
The query cannot be completed because the number of lists in the query exceeded the allowable limit. For better results, limit the scope of the query to the current site or list or use a custom column index to help reduce the number of lists.
Any ideas?
August 30th, 2011 at 6:01 am
@Brad: could it be that the Web Part is returning too many tasks exceeding the throttling limit?
September 15th, 2011 at 11:55 pm
Not working for me, everytime I try it I get:
An error has occurred.
Cannot complete this action. Please try again.
My code is identical to yours, is there anything else I can try?
September 16th, 2011 at 6:41 am
@Frank: Have you included the xmlns attribute? Additionally you could try to check the ULS log for more details.
September 16th, 2011 at 6:37 pm
Thanks for the reply, it turns out there was a problem with a task list on a subsite, when that was deleted the webpart displays perfectly.
Thanks for this great info!
September 28th, 2011 at 6:26 pm
Thanks a lot!!
this have been really helpful; but i have a question, is there any way to do the same with the calendars?
September 28th, 2011 at 6:32 pm
@Gado: User Tasks Web Part is a standard Web Part. As far as I know there is no such Web Part for calendars. Nevertheless you could create a similar overiew using one of the other SharePoint Web Parts depending on your requirements.
November 17th, 2011 at 1:20 pm
This is a great solution…You are a genious….
December 14th, 2011 at 2:20 pm
I am getting the following:
An error has occurred.
The query cannot be completed because the number of lists in the query exceeded the allowable limit. For better results, limit the scope of the query to the current site or list or use a custom column index to help reduce the number of lists.
What is the advised solution for a large number of sites; search?
Thanks,
Will
December 14th, 2011 at 5:09 pm
@Will: You're right. Search would be a better choice if you have a lot of sites to gather information from. The downside of using search is that the displayed information isn't real time and its freshness depends on how you tuned the crawling process.
February 9th, 2012 at 7:35 pm
@Asher and knyazs – do you still need the User Tasks Web Part to display tasks if it is assigned to a group the user is in? I have mine displaying all tasks in a site that are assigned to [Me] and any group I'm in, as well as grouping the tasks by site. I also have it displaying tasks in a table/grid and am working on the grouping/sorting issue I'm experiencing with this.
February 21st, 2012 at 8:09 am
@Jess please share the "assigned to group" solution…!