Inconvenient User Tasks Web Part and how to make it display all tasks

, , , ,

SharePoint 2010 User Tasks Web Part showing all tasks assigned to the current user.
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.

User Tasks Web Part on a SharePoint 2010 Team Site showing one task.

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.

Export… menu item highlighted in the context menu of the User Tasks Web Part.

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>

The QuerySiteCollection element highlighted inside the .dwp file in Visual Studio 2010.

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:

SharePoint 2010 Team Site with two User Tasks Web Parts. The first displays two tasks, the second one displays one task.

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.

Technorati Tags: ,


Possibly related posts

33 Responses to “Inconvenient User Tasks Web Part and how to make it display all tasks”

  1. Jasper Says:

    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?

  2. Andy Burns Says:

    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…

  3. Waldek Mastykarz Says:

    @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.

  4. Waldek Mastykarz Says:

    @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.

  5. Andy Burns Says:

    @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!

  6. Andy Burns Says:

    Sorry, as a random question, how did you find out about the QuerySiteCollection element?

  7. Waldek Mastykarz Says:

    @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.

  8. Rick Hilferink Says:

    Great option indeed, too bad that it doesn't display tasks from the "Project Task" list definition..

  9. Asher Says:

    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

  10. Asher Says:

    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

  11. Waldek Mastykarz Says:

    @Asher: I'm not sure how SharePoint internally translates the Assigned To: Me value. The best way would be to test it.

  12. Esther Says:

    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.

  13. David Vaello Says:

    Thank you sharing this tip.
    Note you can use this tip with "Relevant Documents" webpart (UserDocsWebPart).

  14. knyazs Says:

    Anyone managed to "make" Users Tasks Web Part to show tasks assigned to groups?

  15. Chang Says:

    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?

  16. Barbara Says:

    Hi Waldek,
    you're always one step ahead! Thanks!
    Can I post your trick on my Italian blog?

  17. Waldek Mastykarz Says:

    @Barbara: Thanks! Sure and I would appreciate it if you included a link to this post as well.

  18. Barbara Says:

    Thanks and Yes, for sure… Done it!

  19. Rudiger Says:

    Is it possible to get this to work for "Project Tasks" as well?

  20. Madhu Says:

    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?

  21. Waldek Mastykarz Says:

    @Madhu: did you add the xmlns attribute as well? It won't work without it…

  22. Brad Burns Says:

    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?

  23. Waldek Mastykarz Says:

    @Brad: could it be that the Web Part is returning too many tasks exceeding the throttling limit?

  24. Frank Says:

    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?

  25. Waldek Mastykarz Says:

    @Frank: Have you included the xmlns attribute? Additionally you could try to check the ULS log for more details.

  26. Frank Says:

    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!

  27. Gado Says:

    Thanks a lot!!
    this have been really helpful; but i have a question, is there any way to do the same with the calendars?

  28. Waldek Mastykarz Says:

    @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.

  29. Denny Says:

    This is a great solution…You are a genious….

  30. Will Says:

    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

  31. Waldek Mastykarz Says:

    @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.

  32. Jess Says:

    @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.

  33. AF Says:

    @Jess please share the "assigned to group" solution…!

Leave a Reply

Security Code:

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS
Copyright © 2007 - 2012 Waldek Mastykarz

Creative Commons License