Catalog Item Reuse Web Part doesn’t show Managed Property Values from DateTime Type
This post is over a year old, some of this information may be out of date.
Last week I was doing some experiments with the creation process of page layouts for a cross-site publishing site. After a couple tests with different types of data, I saw some weird behavior when using DateTime managed properties. The Catalog Item Reuse web part didn’t show the value for a managed property of DateTime type. The auto-created managed property for that DateTime field worked correctly, but my custom one didn’t.
This were the values for my auto-created managed property:

The difference between the auto-created property and the custom property is the data type that is specified.

Auto-created managed properties for a DateTime field are set to Text. My custom property was set to Date and Time because I also need it for filtering and sorting.
The values which these managed properties return are also very different:
- Text value: “PublicationDateOWSDATE”:“2014-02-11T23:00:00Z”;
- Date and Time value: “PublicationDate”:“/Date(1392159600000)/”.
After some digging in the assembly of the Catalog Item Reuse web part (Microsoft.Office.Server.Search.WebControls.CatalogItemReuseWebPart), I found that it does a parsing from a string to a DateTime. That way, you’re custom values would never be converted correctly.
private static string GetDateTimeValue(string searchData, bool dateOnly){ DateTime time; string str = searchData; CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; if (DateTime.TryParse(searchData, currentCulture.DateTimeFormat, DateTimeStyles.AssumeUniversal, ref time)) { str = dateOnly ? time.Date.ToString("D", currentCulture.DateTimeFormat) : time.ToString("f", currentCulture.DateTimeFormat); } return str;}
Another downside of the catalog item reuse web part, is that you cannot define the format of your date time. You only have the option to show the time or not.
If you want to do some formatting to your DateTime values, the best option you have is to visualise it with a Content Search Web Part.
Important:: this blog post is written based upon my findings in SharePoint 2013 with the December 2013 CU installed.
Related articles
Checking which Managed Properties are available for your Catalog Items
Client side managed property value formatting for catalog item page layouts
Things you need to know about anonymous permissions with the cross-site publishing functionality
Report issues or make changes on GitHub
Found a typo or issue in this article? Visit the GitHub repository to make changes or submit a bug report.
Comments
Let's build together
Manage content in VS Code
Present from VS Code