User Voices
(Loading...)
Our blog on SharePoint add-ons and solutions development
« FilterZen how-tos: live-filter as-you-type; embed filters under Column headers | Main | Manual installation / deployment of our SharePoint WSP Solution Packages »
Sunday
Sep252011

Using User Profile Property Values for List Filtering in SharePoint

Every other month or so, we receive an enquiry like the following:

Is it possible to filter (using FilterZen) a standard Document Library by a specific user profile field such as Department, where Department is also a field in the List / Library? I cannot see a way of doing it like the out-of-the-box Current User Filter Web Part.

Can do! With a few tweaks. Truth be told, we've been meaning to roll out first-class native FilterZen support for the SharePoint Server (MOSS / SPS) User Profiles model for a bit now. We expect to finalize an update for this by early October 2011, ie. in the next 1-2 weeks.

But that's no excuse not to implement such a requirement in FilterZen right now, with the current version you have now available. Of course, if you're on MOSS 2007 / SPS 2010, you could just use the out-of-box Current User Filter Web Part right away and skip FilterZen entirely — but if you have other filters for your List or Library you'd like to apply with FilterZen, integrating a User Profile Property into your main FilterZen Web Part is an understandable need and this is how you do it:

Let's work from the original enquiry above. You have a List View / Library View Web Part on your page (or you work directly on a View Page for that Library) and the Library contains a Department field. We want to filter so that only documents are shown that apply to the current user's Department, as stored in the corresponding User Profile Property.

For now there are no other Web Parts on the page. Add to it an out-of-box Current User Filter Web Part, a FilterZen Transformer Web Part and a FilterZen Filter Web Part, in that order. Do not connect any Web Parts at this point. Since you can freely re-arrange the order of Web Parts on the page interactively, be sure we have the following Web Part order:

  1. Out-of-box Current User Filter Web Part
  2. FilterZen Transformer Web Part
  3. FilterZen Filter Web Part
  4. Your Library View Web Part

1. The Current User Filter Web Part

  • For Filter Name, specify TempDepartment
  • Under Select value to provide, pick Department
  • Under Advanced Filter Options, tick the Send Empty if there are no values check-box option

2. The FilterZen Filter Web Part

Apart from any other filters your FilterZen Filter Web Part may contain, you will add a Text Filter named Department. This filter name refers not to the User Profile Property but to the target Library Field it is filtering! Apart from the name, the only other setting you need to set for this Text Filter is the default value which you will set to {$TempDepartment$} (or whatever name you used in step 1.)

3. Web Part Connections

Only now do you connect all Web Parts on the page, exactly as follows and exactly in this order:

  • From the Connections sub-menu of the FilterZen Transformer Web Part, select ICellConsumer (Get Cell From) and then pick your Current User Filter Web Part.
  • From the Connections sub-menu of the FilterZen Transformer Web Part, select IRowProvider (Send Row To) and then pick your FilterZen Filter Web Part.
  • From the Connections sub-menu of the FilterZen Filter Web Part, select Send Filter Values To and then pick your List View / Library View Web Part.

At first glance, this possibly looks more complicated than it really is — in fact, it's a fairly straightforward sequence of simple steps, really! With the next FilterZen, as usual things will be even easier and even faster to implement. But even now, FilterZen's core flexibility let's you combine the (very few) remaining not-yet-fully-absorbed skills of out-of-box Filter Web Parts with its many rock-solid and tremendously useful capabilities already provided.

This was just one example of how experimentation with core building blocks and re-using basic capabilities can take you far beyond the myriad of built-in, "typical" turn-key use-cases. So keep exploring!

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>