Configure Document Review Process Using DVWP and XSL

Products:  SharePoint Designer 2007, 2010; Custom Data View Web Part; XSL

Requirements

  • each Content Owner responsible for content (ie: documents, links, etc.) within a document library will be accountable for keeping their content up-to-date
  • each Content Owner will need to be aware of those documents within X number of days prior to the Review Due date
  • each Content Owner will update their documents prior to the Review Due date

Library Column Definitions

A typical library contains the typical Name and Title columns; add the following columns required for this process:

  • Cycle Days … a calculated column normally set to a value of 30, 60 or 90 days
    * defined as the number of days between the Modified and Review Due dates
  • Notify Days …. a calculated column normally set to a value of less than Cycle Days
    * defined as the number of days from the Modified date when the document will be visible on the view
  • Content Owner … a people/group field
    * include the name of the employee responsible for each document
  • Modified Date … the date the document was last updated by the Content Owner

Today’s Date

The remaining functionality to handle the review process for each document will reside within the DVWP XSL template functions.

But, if SharePoint provides calculated columns, why can’t we simply add a few columns to calculate future dates and date differences based off the Today or Current Date to handle our review process?  That’s a great question and the average power user would pursue that path until testing showed the frustrating results … that the original ‘Today’ date is static at the time of its creation and that other dependent calculated fields are not performing as expected. The effort is futile. Stop. See the References section below for additional information.

Instead, resolve that the DVWP will handle the additional details. 

Review Due Calculation

The Review Due is a future date by which we need the Content Owner to have a document reviewed and updated. Once updated, the Modified Date will be set to Today’s Date and the Review Due date will then be updated to the next future date. The formula will resemble the following:

[Modified Date] + Cycle Days = [Review Due Date]
    4/19/2014     +       90          =    approx 7/19/2014

NOTE:  The is a visual target for the Content Owner to meet or exceed. 

Notify Date Calculation

The Notify Date is a future date by which we want the Content Owner to be aware that a document review is needed and that the count-down has begun.  In this scenario, the Notify Days value is considered to determine if the document falls within this ‘window of opportunity’ for the Content Owner. The formula will resemble the following:

[Modified Date] + Notify Days = [Notify Date]
    4/19/2014     +       60          =    approx 6/19/2014

NOTE:  A document will continue to show on the review list until the document OR the document related metadata properties are updated within the library.

Prepping The DVWP Page

I am making an assumption that you already have experience creating a DVWP ASPx page where you have inserted the following:

  • a SharePoint Control – Web Part Zone,
  • a SharePoint Control – Data View

And

  • you have connected the Document Library of your choosing to the Data View and
  • selected the following columns at a minimum
    • Name
    • Content Owner
    • Cycle Days
    • Notify Days

Enable Header Column Sorting

To allow the users to sort and filter on specific columns (ie; Name, Content Owner, etc.) that originate from the original list, follow these steps:

  • select the Data View menu option
  • select Paging
  • select the General tab
  • select Enable Sorting and Filtering on Column Headers

Grouping

As the client requests the documents eligible for review be grouped by Review Due date, we must manipulate the view to achieve the required results.  As the Modified date of each document is the baseline for our review process, we simply use that date to our advantage and configure the Data View as follows:

Sort

  • select the Modified date column
  • select ‘ascending’ sequence

Grouping

  • select Show Group Header
  • select Expand Group by Default
  • within Advanced Grouping,
    select Show Column Names per Group

As the view shows the grouping by Modified date, we need to update that section to show that the grouping is really related to the Review Due date; update the related section similar to the following:

<!-- <b><xsl:value-of select="$fieldtitle" /></b><xsl:if test="$fieldtitle">: </xsl:if> //--> 
<xsl:text>Review Due: </xsl:text>
<xsl:choose>
 <xsl:when test="$fieldtype='url'">
  <a href="{$fieldvalue}">
   <xsl:value-of select="$fieldvalue" />
  </a>
 </xsl:when>
 <xsl:when test="$fieldtype='user'">
  <xsl:value-of select="$fieldvalue" disable-output-escaping="yes" />
 </xsl:when>
 <xsl:otherwise>
  <xsl:call-template name="calcDate">
  <xsl:with-param name="date" select="substring-before(@Modified,'T')" />
  <xsl:with-param name="days" select="@CycleDays" />
  </xsl:call-template>
<!--  <xsl:value-of select="$fieldvalue" /> //-->     
   <xsl:text>(</xsl:text><xsl:value-of select="count($nodeset/@FileLeafRef)" /><xsl:text>)</xsl:text>
 </xsl:otherwise>
</xsl:choose>

Date Difference Template

As we need to understand where each document is within the review cycle, we will calculate the difference (in Days) between the following dates:

  • Today’s date (ie; 3/25/2014) and the Modified date (ie; 1/15/2014) of the document

To calculate the number of days between the above two dates, the DateDiff Template will need to be included within the Stylesheet section of your DVWP page.  Call the template, supplying the following parameter values and the template will return the number of days value.

<xsl:call-template name="DateDiff">
  <xsl:with-param name="StartDate" select="@Modified"/>
  <xsl:with-param name="TodayDate" select="ddwrt:Today()"/>
</xsl:call-template>

Accomplish the above by following these steps to display the value on the view:

  • add an additional column into the view (ie; Title)
  • replace the ‘xsl:value-of select’ for Title with the above call to the DateDiff Template

Add Days Template

As we need to understand the Review Due date for each document, we will use the below fields to calculate the future Review Due date:

  • Modified date  (ie; 1/15/2014) of the document
  • Cycle Days       (ie; 90)

For this scenario, we add 90 days to the Modified date to arrive at our Review Due date.

To accomplish this calculation, the calcDate Template will need to be included within the Stylesheet section of your DVWP page.  Call the template, supplying the following parameter values and the template will return the future date value.

<xsl:call-template name="calcDate">
 <xsl:with-param name="date" select="substring-before(@Modified,’T')"/>
 <xsl:with-param name="days" select="@CycleDays"/>
</xsl:call-template>

Accomplish the above by following these steps to display the value on the view:

  • add an additional column into the view (ie; Created)
  • replace the ‘xsl:value-of select’ for Created with the above call to the calcDate Template

Examples Using Specific Document Details

Scenario #1: Document will NOT display within view

  • Cycle Days:  20
    * the total number of days between Modified and Review Due dates
  • Notify Days:  15
    * this provides the Content Owner 5 days to complete the review and update
  • Modified date (ie; 3/01/2014) of document
  • Notify Due date (ie; 3/16/2014) <—— Date not reached
  • Today’s date (ie; 3/13/2014) <—— Date prior to Notify Due
  • Review Due date (ie; 3/21/2014)

Scenario #2: Document WILL display within view

  • Cycle Days:  20
    * the total number of days between Modified and Review Due dates
  • Notify Days:  15
    * this provides the Content Owner 5 days to complete the review and update
  • Modified date (ie; 3/01/2014) of document
  • Notify Due date (ie; 3/16/2014) <—— Date reached
  • Today’s date (ie; 3/18/2014) <—— Date after Notify Due
  • Review Due date (ie; 3/21/2014)

Filter

    • include all entries with a metadata column value of X
    • include all entries where the Content Owner is equal to [ME]

Summary

Your mileage may vary; in escence, the solution options are endless and are only limited by your creativity and/or project requirements. 

The main emphasis or requirements of this solution encompassed the following:

  • provide visibility of those documents requiring review and updates
  • provide visibility of the Content Owner responsible for each document
  • provide visibility of the document review due date(s)

References – Worthless ‘Today’ Trick

References – DVWP & XSL

Feedback welcome.

How has SharePoint affected you?

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

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s