SharePoint Search Scenario Background
Search is going to be a key part to any business management system in Office 365 and SharePoint. In this post, we mapped our crawled Expires Date property to the Managed Property named RefinableDate00. Afterwards, the refiner date was customized for the Search Results on our Sales Contracts Quick Search page. 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 first issue is with the time stamp (e.g. “07:00:00 AM”) showing up in the results. When the field Expires Date field was created, it was set to a “Date Only” field because time is irrelevant to the expiration date of these sales contracts. 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
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 some JavaScript to manipulate and reformat that date value into what we want: an English-US date format with no time stamp.
- Write the custom HTML that outputs the new date how we want…with a label in front of it.
Ready?
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.
Categories: Business, Business Management, Contract Lifecycle Management, Office 365 and O365, SharePoint
Leave a Reply