Dev Notes

Notes on Development with Microsoft Technologies

Date Range Custom Refiner

5 Comments

Recently, I had a project where a group wanted to show an aging report using SharePoint’s search capabilities. The easiest way to accomplish this is the use of refiners, but I struggled with this quite a bit until I figured out that the left argument of the custom value must ALWAYS be less than the right argument. Here was my final refinement XML markup:

 <Category Title="Aging" Description="Aging groups for items based on the submission date"
  Type="Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator"
  MetadataThreshold="3" NumberOfFiltersToDisplay="5"
  MaxNumberOfFilters="0" SortBy="Custom" ShowMoreLink="True"
  MappedProperty="SubmitDate" MoreLinkText="show more"
  LessLinkText="show fewer">
    <CustomFilters MappingType="RangeMapping" DataType="Date"
    ValueReference="Relative" ShowAllInMore="False">
      <CustomFilter CustomValue="0-30 Days">
        <OriginalValue>-30..0</OriginalValue>
      </CustomFilter>
      <CustomFilter CustomValue="30-60 Days">
        <OriginalValue>-60..-30</OriginalValue>
      </CustomFilter>
      <CustomFilter CustomValue="60-90 Days">
        <OriginalValue>-90..-60</OriginalValue>
      </CustomFilter>
      <CustomFilter CustomValue="60-90 Days">
        <OriginalValue>-120..-90</OriginalValue>
      </CustomFilter>
      <CustomFilter CustomValue="120+ Days">
        <OriginalValue>..-120</OriginalValue>
      </CustomFilter>
    </CustomFilters>
  </Category>

This is part of a much larger application that has several search customizations, but you could use this with any out of the box managed properties dealing with dates.

If you want more details on custom refiners, check out Michal Prisarek’s Custom Refinement Filters in SharePoint 2010 Overview. This is a great overview of custom refiners and was one of my jumping off points for this project.

Advertisements

Author: Chris Quick

I have been a developer of web based solutions since early 2001 delivering solutions to a wide array of organizations using ASP, ASP.NET and SharePoint. I was introduced to SharePoint in 2003 when the consulting firm I worked for at the time introduced it into the workplace. I began working with MOSS 2007 as soon as Microsoft released the RTM version in November 2006. The platform was implemented at the organization I worked for in 2007 and went live in March of that year. I was tasked with the administration and ongoing development of the platform. I currently work as a SharePoint Architect with Artis Consulting, developing solutions for a wide variety of business problems. The goal of this blog is to share my discoveries developing solutions with SharePoint. I welcome your comments and feedback to any post -- and I welcome suggestions for future topics.

5 thoughts on “Date Range Custom Refiner

  1. Hi
    Do you know how to do this in sharepoint 2013?

  2. I personally blog also and I’m posting a thing comparable to this particular post, “Date
    Range Custom Refiner | SharePoint Dev Notes” ocomp .
    Would you care in cases where Iapply a number of of your own tips?
    Thanks for your effort ,Jillian

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