Custom Web Part for Birthday or Anniversary

Technologies: SharePoint 2007-Online; SharePoint Designer 2010-2013; XSL

Purpose: Provide a means to easily manage a list of Contacts and related metadata pertaining to Birthdays, Anniversaries, Engagement Dates, Opportunity Dates, etc. The people and content related to the current month will display. This provides a long-term low maintenance architected solution for an Office Admin or Office Manager role.

Create Contacts List

Column Name                  Column Type

  • Full Name                        People
  • Birth Month                    Choice
  • Anniversary Month      Choice
  • Anniversary Date          Date/Time

Open SharePoint Designer and perform the following operations

Page Setup

  • create a new ASPX page
  • add an empty data view web part
  • insert the data source list of Contacts


  • include only those entries from the Contacts list where the Anniversary Month relates to the current month

<xsl:variable name=”Rows” select=”/dsQueryResponse/Rows/Row[@AnnivMonth=number(ddwrt:FormatDateTime(string(ddwrt:Today()),1033,’MM’))]”/>


  • show the resulting entries in ascending sequence by Last Name


  • insert two(2) columns to display (ie; Name, Anniversary Date)
    * these are place holders for now
  • retain the column header of ‘Name’
  • change the column header of ‘Anniversary Date’ to ‘Service Years’

Column Headers

<tr valign=”top”>
  <th class=”ms-vh” nowrap=”nowrap”>Name</th>
  <th class=”ms-vh” nowrap=”nowrap”>Service Years</th>

Within the template named ‘dvt_1.rowview’, calculate the years of service which is the difference between ‘Today’ and the Anniversary Date

<xsl:variable name=”yearsOfservice”
– number(ddwrt:DateTimeTick(ddwrt:GenDisplayName(string(@AnnivDate))))) div 864000000000)
div 365)”

Column Details

  • display the Contact Name

   <td class=”ms-vb”>
    <xsl:value-of select=”@Title”/>, <xsl:value-of select=”@First_x0020_Name”/>

  • display the Years of Service
    * show the actual number of years when the value is not equal to 0

<td class=”ms-vb”>
    <xsl:when test=”$yearsOfservice != ‘0’”>
 <xsl:value-of select=”$yearsOfservice”/>
 &lt; 1 Hire

That’s it. Short and sweet.

Save the Web Part

  • position your cursor in the detail area of the web part, select the Web Part tab and save the file locally

Insert onto your Page

  • edit the page where the web part will display
  • upload the Web Part
  • insert onto the page and configure as needed

Leave me a comment if you need any assistance with your project.

Enjoy every sandwich !

This entry was posted in Data View Web Part, SharePoint Designer, Web Parts, XSL. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s