We’ve already agreed that Search is going to be a key part to your business management system in Office 365 and SharePoint. In this post, we mapped our crawled Expires Date property to the Managed Property named RefinableDate00. We then used that refiner date to customize the Search Results on our Sales Contracts Quick Search page with the “Two Lines” Display Template. That’s shown in the first image below. Also called out in that post: for the Contract Lifecycle Management (CLM) system, the dates were not in the right format because they included a timestamp.
The Sales team was not happy with that time stamp (e.g. “07:00:00 AM”) showing up in the results. When they created the Expires Date field, they created it as a “Date Only” field because time is irrelevant to the expiration date of a sales contract. Also, not everybody is familiar with the design of the page, so without a label like “Expires: ” before the date/time value, a user won’t necessarily be able to determine exactly what that date represents. In this post, we’re going to fix that date to be a standard US-English date format without a time stamp, and we’re going to get a label in the results as well.
Reviewing the Refiner Managed Property RefinableDate00
Something to note about the RefinableDate00 managed property that we created here: I also added an Alias value to the Managed Property definition so that I can refer to “RefinableDate00” as something more identifiable when its used in scenarios like the one covered herein. Later on, when I use “ExpireDateRefinable” in the Search DisplayTemplate…this is why:
Creating the new Display Template for the Contract Lifecycle (CLM) Search Results
As with many posts in this series, I have to assume you’ve followed along. Here, my assumption is that you enabled the Publishing Infrastructure as we covered in this post. If you didn’t, the Master Pages gallery you’re about to see will not look the same. So, here’s what I’m going to do:
- Go to the Master Page gallery.
- Navigate into the Display Templates used for Content Search Web Parts…because the Sales Contracts Quick Search page is based on a Content Search Web Part (CSWP).
- Locate the Display Template used for “Two Lines”…because that’s what we chose when setting up the quick search page.
- Download that template.
- Fix it up to have a reference to the RefinableDate00 (a.k.a. ExpireDateRefinable) property so that I can use that property in my custom HTML.
- Write the custom HTML that outputs the new date how we want…with a label in front of it.
Applying the new SharePoint Search Display Template
Now, it’s time to:
- Upload the new Display Template.
- Publish the template.
- Reset the CSWP properties on the Contracts Quick Search page (to use our new template).
- Validate the results.
Of course, you can repeat this pattern to add additional important fields.
- Promote the crawled property to a managed property.
- Pull the managed property into the SharePoint Search Display Template by adding it to the ManagedPropertyMapping XML element.
- Pull the value from ctx.CurrentItem.
- Validate/manipulate that value.
- Output it into the Display Template.