WebDrawer (and Web Client) auto filter search

While all users may configure default filters and have ACLs restricting access to certain records it can be desirable to configure an instance of WebDrawer to only return a subset of Records.  Maybe this is the planning portal and you only want it to return planning permission related Records?

Filter WebDrawer

The hptrim.config file contains a section called routeDefaults, there are two of these elements you will need to modify.  The first has the model 'Records', add a filter attribute as seen below.   This example filters out all .doc files.

<add
    name="Record"
    model="Records"
    template="WDRecordList"
    filter="not extension:doc"
    properties="RecordRecordType,RecordExtension,RecordTitle,RecordNumber,RecordIsElectronic"
/>

If you are using custom search forms you will also need to filter the FormSearch route.

<add
      name="FormSearch"
      model="FormSearch"
      filter="not extension:doc"
      properties="RecordRecordType,RecordExtension,RecordTitle,RecordNumber,RecordIsElectronic"
/>

Filter Web Client

The Web Client may be similarly filtered, edit hptrimServiceAPI.config and edit the Records route, as seen here:

<add
   name="Record"
   model="Records"
   filter="not extension:doc"
   sortBy="recRegisteredOn- unkUri"
   includePropertyDefs="true"
/>

Saved Searches

A slightly more elegant twist on the above approach is to not use the actual search string but to use a saved search.  The example below filters using the Saved Search named 'NotDocuments'.

<add
   name="Record"
   model="Records"
   template="WDRecordList"
   filter="saved:NotDocuments"
   properties="RecordRecordType,RecordExtension,RecordTitle,RecordNumber,RecordIsElectronic"
/>

Be Careful

It is best to not copy the XML snippets directly to your config file as the other attributes may be different in your version.  Just add the filter attribute.

Written on August 9, 2016