Content Query Web Part on SharePoint 2010 supports multi-value lookup fields

Content Query Web Part on SharePoint 2010 supports multi-value lookup fields

  • Comments 7
  • Likes
That is probably the geekiest blog title I have ever written.  Sorry.  This is just a very cool change between 2007 and 2010 that will probably never make it to a marketing slide, but which solves a frustration that I experienced with 2007.

Why is this important?  Let me walk you through an applied example.  Out of the box on SharePoint 2007, Blogs allow for only a single category.  This, of course, sucks.  If I write a post about installing SharePoint 2010 on Windows 7, I would like to categorize it as “SharePoint 2010” and “Windows 7”.  The workaround is simple and documented (in a video no less) by Lawrence Liu (who has since moved on to Telligent) here: Configuring SharePoint to allow multiple categories per blog post.

This works great, but let’s say that the Sales, Legal, and Marketing teams at Contoso have all established blogs (with multiple categories) on their own web sites, and we would now like to aggregate some of their posts (any posts with a category of Foo) on the front page of our Intranet portal.  To do so, we add a Content Query Web Part to the front page, set the scope to our site collection, and filter to show items when Category is equal to Foo.

image

While this works fine with blogs that only allow a single category, here’s what we get if the Marketing blog has a category of “Foo” and “Bar”.

image

Frustrating.  Waldek Mastykarz (a SharePoint Server MVP out of the Netherlands) has some workarounds to this problem that include custom multi lookup fields or custom XSLT functions.

Enter… SharePoint 2010.  First of all, right out of the box you can add multiple categories to a post.  The UI below is what you get when creating a post through the web interface, but I still prefer using Windows Live Writer.

image

What does this do to content queries? Let’s add a content query web part to our front page.

image

As with 2007, set our source scope to the site collection, with a list type of “Posts”.

image

We’ll filter to only show blog posts where the category is equal to foo (as before), and we’ll also filter out those “Welcome to your Blog!” posts that nobody remembers to delete.

image

Voila!  The content query (which is being run against a multi-value lookup field) successfully completes.  Sweet!

image

* Disclaimer: SharePoint 2010 is in beta.  I’m not on the product team, and for all I know this capability may or may not make it to RTM. This functionality qualifies for Jeff Atwood’s “works on my machine” certification.

*Update: I spoke with a Dev on the SharePoint team, and this will only work in narrow circumstances.  The CQWP in SharePoint 2010 will support querying multi-value lookup fields against a single list, or single-value fields in multiple lists, but not both at the same time.  It appears that the Category field used by blogs may be an exception to this rule.

image

Comments
  • Can you set the filter for a date field to return only this MONTH?

  • Hi,

    I have one question regarding content query. How can I use Custom Query field in it?

  • Hello, why I did not find the content query 2010, which controls, is the Chinese version of my

  • Can i able to view more columns in content query webpart

  • good  and  Nice post. The way you written is appreciated

    sharepointsolution2010.blogspot.com/.../show-additional-columns-from-lookup.html

  • I like your Post very much and It is very interesting. I will use this Info to Develop the SharePoint Applications. Thanks for share this valuable Information.

    www.box.com/.../fa322ee3eb36ff5d350c

  • More info on CQWP

    sharepointnadeem.blogspot.in/.../sharepoint-2010-content-query-webpart.html

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment