Defining custom search panels for DMF and Message

MacroView DMF and MacroView Message search panels can be customized by modifying an XML definition file.  For information on where to find the XML definition file refer to FAQ: MacroView DMF and MacroView Message search panels.
 
Below is a sample of the supplied email search panel and it associated XML definition.  


Search mask definition:
<?xml version="1.0" encoding="utf-8" ?>
<SearchMasks>
  <Mask Name="Email Search" TrimDuplicates="False" EnableStemming="True" Scope="All Sites" >
    <Controls>
      <Control Name="mvTo" Type="Text" DisplayName="To" />
      <Control Name="mvFrom" Type="Text" DisplayName="From" />
      <Control Name="mvSubject" Type="Text" DisplayName="Subject" />
      <Control Name="mvImportance" Type="Dropdown" DisplayName="Importance" >
        <Item DisplayName="Low" Value="0" />
        <Item DisplayName="Normal" Value="1" />
        <Item DisplayName="High" Value="2" />
      </Control>
      <Control Name="FileExtension" Type="Hidden" Value="msg" />
      <Control Name="mvReceivedTime" Type="DateRange" DisplayName="Received Time" />
      <Control Name="mvHasAttachments" Type="Checkbox" DisplayName="Has attachments?" Value="0" />
      <Control Name="AllText" Type="Text" DisplayName="All of these words" SearchPredicate="FreeText" />
      <Control Name="mvCheckoutUser" Type="Checkbox" DisplayName="Checked out to me" Value="[Me]"/>
    </Controls>
    <SelectFields>
      <Field Name="mvSubject" DisplayName="Subject" />
      <Field Name="mvTo" DisplayName="To" />
      <Field Name="mvFrom" DisplayName="From" />
      <Field Name="mvReceivedTime" DisplayName="Received Time" Type="DateTime"/>
      <Field Name="Path" DisplayName="Url"/>
      <Field Name="SiteName" />
    </SelectFields>
  </Mask>
</SearchMasks>


 
Each additional search panel is defined between a new set of <Mask Name=”[MASK_NAME]”…> and </Mask> tags in the search mask definition.  Each mask is made up of:
  • panel name and scope definiton
  • panel controls
  • result columns
  • refiners (optional)
Defining the panel name and scope
 
Panel name 
The panel name is define as follows:
<Mask Name="Email Search" TrimDuplicates="False" EnableStemming="True" 
 
Search scope
 
Search Scopes can be mapped to upgraded search scopes or to newly created result sources for SharePoint 2013/2016.
 
Using a search scope

To modify the search scope to use something other than the default mvAllSites scope add the search scope to the mask definition as follows:

<Mask Name="Email Search" TrimDuplicates="False" EnableStemming="True" Scope=”[SCOPE_NAME]”>
 
Where [SCOPE_NAME] must be a valid source.  For example, in a Dutch language implementation of SharePoint a valid Scope would be ‘Alle Sites’ (corresponds to All Sites in English). As illustrated above, the ‘Scope’ setting is optional, with 'mvAllSites' being used if it is missing.
 
Using a result source
 
You can also use Result Sources to target searches by specifying the result source in the mask header as follows:
 
<Mask Name="Display name" TrimDuplicates="False" EnableStemming="True" Scope="Result Source Name">
 
For more information refer to Using result sources to target searches
 
Using term sets defined at the site collection level
 
If your search panel uses the Search Taxonomy Control to allow the selection of a value from a managed metadata term set that is defined at the site collection level rather than the tenancy level, you need to also specify the site collection URL where they are defined as follows:
 
<Mask Name="Display name" TrimDuplicates="False" EnableStemming="True" SiteCollectionUrl="https://mytenacy.sharepoint.com/sites/sitename">
 
Where clause
You can also further limit the scope by adding a "Where" clause using a path or content type as follows:
 
Filtering by path
 
<Mask Name= "Email Search" TrimDuplicates="False" EnableStemming="True" Scope="All Sites" Where="path:https://my.sharepoint.com/sites/location/*" > 

Note: The asterisk at the end of the path in the Where clause is required.
 
Filtering by content type
 
<Mask Name= "Email Search" TrimDuplicates="False" EnableStemming="True" Scope="All Sites" Where="ContentTypeId:0x01*"
 
For more information refer to Filtering search masks on content type and Limiting results using "WHERE" in search masks
 
Duplicate Trimming
The ‘TrimDuplicates’ option in MacroView DMF search panels specifies whether duplicate items should be removed from the search results. The default behavior in MacroView panels, and the SharePoint UI, is to show duplicates. If this option is changed in your search panel XML definition, you may receive far less results than the equivalent browser search.

TrimDuplicates is defined in the <Mask> tag as follow:
 
<Mask Name="Email Search" TrimDuplicates="False" EnableStemming="True">
 
Word Stemming
The ‘EnableStemming’ option in MacroView DMF search panels specifies whether the SharePoint search should use word stemming. Stemming is a process where the endings of some words are stripped off to facilitate a search that returns results including related words, such as ‘kick’, ‘kicks’ ‘kicking’, ‘kicked’ etc. The default behavior in the SharePoint UI is for stemming to be disabled. The default behavior in MacroView panels is for stemming to be enabled. You can modify your search panel XML definition if you would like to match the browser search.

EnableStemming is defined in the <Mask> tag as follow:

<Mask Name="Email Search" TrimDuplicates="False" EnableStemming="True">
 
 
Defining the panel controls

The controls on the search panel are defined between the <Controls> and </Controls> tags.  Each individual control is defined between a <Control> and </Control> tag.

In the above email search panel example, a text control labelled “To” is defined and associated with the internal column “mvTo” as illustrated here:

 <Control Name="mvTo" Type="Text" DisplayName="To" />
 
Available control types are:

Text

<Control Name="mvSubject" Type="Text" DisplayName="Subject" />

Dropdown

<Control Name="mvImportance" Type="Dropdown" DisplayName="Importance" >
        <Item DisplayName="Low" Value="0" />
        <Item DisplayName="Normal" Value="1" />
        <Item DisplayName="High" Value="2" />
</Control>

For more information and samples refer to Using the DropDown control in search panels

DateRange

<Control Name="mvReceivedTime" Type="DateRange" DisplayName="Received Time" />

Checkbox

<Control Name="mvHasAttachments" Type="Checkbox" DisplayName="Has attachments?" Value="0" />

TaxonomyPicker

<Control Name="mvExample|5abwe60637384ced9ac46109921d3b94|f9552dba-de9a-429c-bd4f-18192f848f5f|https://yourtenancy.sharepoint.com/sites/sitecollection|AND" Type="TaxonomyPicker" DisplayName="Taxonomy" />

For more information and samples refer to Using the TaxonomyPicker control in search panels

Hidden

By setting Type="Hidden" in a search mask control you can hide the control from users.

<Control Name="FileExtension" Type="Hidden" Value="msg" />

In the above example, a hidden control is used to define Email messages as files that have a file extension of ‘msg’.

You might also use a hidden control type as another way of limiting the results by defining a Value for it to filter results on.

<Control Name="mvClient" DisplayName="Client" Type="Hidden" Value="Acme" />

 
Other optional control parameters include:

MatchType

<Control Name="AllText" Type="Text" DisplayName="All of these words" SearchPredicate="FreeText" MatchType="AllText" />
<Control Name="Exact" Type="Text" DisplayName="The exact phrase" SearchPredicate="FreeText" MatchType="Exact"/>
<Control Name="AnyText" Type="Text" DisplayName="Any of these words" SearchPredicate="FreeText" MatchType="AnyText"/>
<Control Name="None" Type="Text" DisplayName="None of these words" SearchPredicate="FreeText" MatchType="None"/>

 SearchPredicate

<Control Name="AllText" Type="Text" DisplayName="Any of these words" SearchPredicate="FreeText" />

AdvancedBooleanSearch

By setting Type="AdvancedBooleanSearch" in a search mask control you can submit any KQL directly.

<Control Name="AdvancedSearch" DisplayName="Advanced Search" Type="AdvancedBooleanSearch" Value="mvClient:Acme" />

For more information refer to Using the "Advanced" control in search masks to submit KQL directly

 
Defining the columns for the search results
 
The fields displayed in the search results pane are defined between the <SelectFields> and </SelectFields> tags.  Each field is defined by its internal column name and the display name for the column.  
 
    <SelectFields>
      <Field Name="FileName" DisplayName="Name" />
      <Field Name="mvDocID" DisplayName="Doc ID" />
      <Field Name="mvClient" DisplayName="Client" />
      <Field Name="mvMatter" DisplayName="Matter" />
      <Field Name="Author" DisplayName="Author" />
      <Field Name="Path" DisplayName="Url"/>
      <Field Name="Write" DisplayName="Modified" />
      <Field Name="Created" DisplayName="Created" Type="DateTime"/>
      <Field Name="SiteName" />
    </SelectFields>
 
For custom date/time columns such as Created in the example above you should also add the Type="DateTime" parameter to ensure the date is displayed in the format defined by your client settings.  If this is not added the date will display in UTC time format.
 
Defining refiners
The fields displayed as search refiners are defined between the <Refiners> and </Refiners> tags.  Each refiner is defined by its internal column name and the display name for the refiner. 
    <Refiners>
      <Refiner name="Size" displaytext="Size" />
      <Refiner name="FileType" displaytext="Result Type" />
    </Refiners>
 
Note: The refiner name tag is case sensitive and the Author property is not refinable by default.  It must be configured in the search service application and a full crawl completed before it can be used.
 
Related Articles:
 
Have more questions? Submit a request

0 Comments

Article is closed for comments.