Monday, February 20, 2023

Microsoft search : using a DateTime field in your Result Types

In one of our products, we are using a Generic SharePoint list to store some information that is required to be visible within a specific timeslot ( beginDate & EndDate).

In the ol' days we could easily exclude those listitems in a data source derived from the LocalSharePointResults data source using a Date variable.


But these days we are dealing with Microsoft Search and a different set of rules.


 Since Microsoft Search will display those list items by default we have a few options:

Option 1: Create two Result Types and use e.g. ContentTypeId and the RefinableDates to handle the items that should be show and not shown respectively.



 Well, this is as far down that path that I got. Date fields in the Result type builder does NOT have any date variables, and according to a very reliable source with Microsoft there are no plans to offer this option.


So, we are left with Option 2 or 3.

Option 2: For each relevant Search Vertical we must add a filter to hide any item outside the range.
(risky as this rule might be forgotten and not implemented in a Vertical added at a letter date)


Option 3: Use the Result Type without any date filter and set up the Adaptive Card to hide any item outside the range.

I am not happy about having "business logic" in the GUI/Display layer but I guess we will go with Option 3 for now.