Archive for September, 2010

Display SharePoint list items based on date range

There was a request to display items (“How-To Tips”) based on a date range.  Seemed like a reasonable request, but I didn’t see anything out of the box that provided this functionality.  To get this done, the obvious choice was to use the Content Query Web Part (CQWP) and create a custom list that contained the tip items.  In the custom list, I created the columns: Tip Description, Tip URL (in case a tip linked to another page/site), Display Start Date and Display End Date and Background Image (the requester also wanted a pretty image for the background of this web part).


Now that I had those columns to work with, I added a CQWP to the page and edited the web part to use my custom list:


To get the date range functionality, I used the Additional Filters section and my Date columns to filter on items with a Display Start Date less than or equal to [Today] and a Display End Date greater than or equal to [Today]. 


All that is left to do is add items to the list that have the correct start and end dates and the tip(s) appear on the web part:



There is more to do with getting the background image.  I will blog that someday.

Leave a comment

KeywordQuery Error: Property doesn’t exist or is used in a manner inconsistent with schema setting

In the following code of a web part that was doing a custom KeywordQuery search, I received the error “Property doesn’t exist or is used in a manner inconsistent with schema settings.”  The Properties that I was adding to the KeywordQuery had not yet been mapped in the Search Service Application, Metadata Properties:

//Get associated search service application
SearchServiceApplicationProxy proxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy

                //Use Keyword Query
                Microsoft.Office.Server.Search.Query.KeywordQuery keywordQuery = new Microsoft.Office.Server.Search.Query.KeywordQuery(proxy);
                keywordQuery.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default;

                //Return following properties          

To map these properties, go to the Search Service Application –> Metadata Properties page in Central Administration –> Application Management.

Select “New Managed Property”


Type the new Managed Property and add a mapping


In my case, I am mapping to properties that were promoted from an InfoPath form.


Once the property is mapped, re-run an incremental or full crawl on your content source which contains the property

Leave a comment