Monday, December 28, 2009 at 0:04 |
Post a Comment An 'Upcoming Birthdays' Web Part in 10 minutes
Cascading, Multiple-Value List Filters,
Employee View,
FilterZen,
MOSS 2007,
People Search,
PeopleZen,
SharePoint 2010,
Staff Directory,
Team Listing,
User Profiles,
Value-Range / Date-Span Filtering,
Web Part Connections,
Web Parts Who doesn't love birthday calendars? So let's add one to your team site! Out of the box, SharePoint does not offer much help with that assignment. What are your options?
- Approach 1: create Your Very Own Birthdays List and commence with your data entry. Problems: your birthdays are likely readily available in Active Directory and/or your SharePoint user profiles, and duplicating them is a waste and not feasible for organizations of significant head count. Furthermore, keeping the list filtered to show, say, the next 14 days only is non-trivial. Try it, and come back here once you've had enough (of calculated Columns that fail to properly understand the Today variable, and of the ensuing Data View Web Part XSLT-fu).
- Approach 2: develop Your Very Own Birthdays Web Part from scratch. Great if you love programming (we certainly do) and have time to spare (we envy you!). Problems: a real Time Sink once you get into the particulars of SharePoint Server's user profiles stores, plus all custom code you write is code you'll have to maintain, support, bug-fix and upgrade for all eternity.
- Approach 3: accomplish it in less than 10 minutes, using only our two most popular and really easy to deploy Web Parts, PeopleZen and FilterZen. Problems: you'd really like to avoid 3rd-party add-ons and wouldn't it be nice to be able to do it out of the box? In an ideal world, maybe. Right now, we invite you to try what we consider the most time-efficient approach using only two proven, tested, usable and supported components.
So we want to list the birthdays coming up in the next 14 days...
On your Web Part Page, switch to Edit mode from the Site Actions menu and add the following two Web Parts:

If they're missing in your environment, simply download and deploy their corresponding Solution Packages for free.
Configuring the User Profiles Web Part
This is the easiest part. From the PeopleZen Web Part menu, choose Modify Web Part. In the tool pane, scroll down to the Filtering section and tick the check box labelled Ignore year when filtering by date-time range properties:

Connecting the Filter Web Part
At this point, it's a good idea to connect the Filter Web Part to the User Profiles Web Part. From the PeopleZen Web Part menu, choose Connections / Get Filters From and pick the filter provider Web Part:

Configuring the Filter Web Part
From the FilterZen Web Part menu, choose Modify Web Part. Scroll down to the Advanced Filtering Settings section and make sure the following settings look exactly like in this screenshot:

Scroll back up to the All Filters section and from the drop-down list of filter types, select Date Filter:

Click the '+' plus icon to actually add a Date Filter to the Filter Web Part. You will see a different tool pane for editing your new Date Filter:

Use the name and the default value illustrated above. Now scroll down a bit and expand the Advanced Filter Properties section. Scroll down again and pick the greater than or equals to operator:

Click Apply to return to the Filter Web Part settings tool pane. Now add a second Date Filter, configured exactly like the first one, with only two crucial differences:
- In the Advanced Filter Properties section, choose the less than or equals to operator.
- In the Date Filter Properties section, enter 14 in the text box labelled Always add N days to the date filter value.
That is, if you want the filtered User Profiles Web Part to only consider birthdays:
- between "Today" (that's what the first Date Filter named SPS-Birthday defined)
- and "14 days from Today" (that's what the second Date Filter named SPS-Birthday defined)
That's it!
Save your Filter Web Part changes, reload the Web Part Page and you will only see those user profiles whose birthday falls within the next two weeks — if there are any. To verify that this works, you can of course experimentally broaden your date range.
Next up: an 'New Collegues / Recent Hires' Web Part in 1 minute...
Of course, there's nothing stopping you from applying and varying those principles to other requirements. A related real-world scenario: listing new employees.
- Instead of SPS-Birthday, you'd use SPS-HireDate throughout.
- Instead of "equals Today" and "less than Today+14", you'd use "greater than Today-14" and "equals Today", in that order.


Reader Comments