Part Filtering

Simple Part Filtering

You can filter selection fields based on values stored in the underlying datastore. Any field in the datastore can be used for filtering.

For example, imagine a datastore called Filtering Examples, containing the following fields:

Field name

Description

Value

The actual selectable value (e.g. the name of a city).

Filter

A secondary field used for filtering (e.g. the country of the city).

Below is an example dataset in this datastore:

Value (City)

Filter (Country)

Bruges

Belgium

Brussels

Belgium

Ghent

Belgium

Amsterdam

The Netherlands

Rotterdam

The Netherlands

Frankfurt

Germany

Dresden

Germany

When entering a filter, set the Filter type to Plain text.

Filter examples

Show only cities from Belgium

[{ "fieldname": "Filter", "filtervalue": "Belgium" }]

Show cities from both Germany and Belgium

[
  { "fieldname": "Filter", "filtervalue": "Belgium" },
  { "connector": "or", "fieldname": "Filter", "filtervalue": "Germany" }
]

Dynamic Part Filtering

Filter based on the value of another part

If you create another part named Country, you can filter using its value:

[{ "fieldname": "Filter", "filtervalue": "#REPLACE-PARTVALUE-Country||#" }]

Important notes

  • Do not add quotes around dynamic values (values coming from other parts).

  • Quotes are required only for hardcoded values such as "Belgium" or "v001".

  • Example of correct dynamic filtering:

[
  { "fieldname": "Version", "filtervalue": "v001" },
  { "connector": "and", "fieldname": "Filter", "filtervalue": #REPLACE-PARTVALUE-Faculty_promotor||# }
]

Please note that no quotes are needed when setting a dynamic value! Quotes are only needed for hardcoded filter values, as in the example above.

For example, with a dynamic filtering:

[{ "fieldname": 'Version', "filtervalue": 'v001' },{"connector": 'and', "fieldname": 'Filter', "filtervalue": #REPLACE-PARTVALUE-Faculty_promotor||Value# }]

Final note: Filters are applied to existing services, so a task runs every 5 minutes to apply any changes. You can kickstart this task by opening this link:

Best Practise with versions

When a template is exported from one installation and then imported in another, you might want to use different values in a select field. To avoid making a new datastore parameter to support this, you can also use filtering. This is how to set it up, do this from the start, to avoid issues when migrating:

  1. Any datastore parameter that is used in a selection field, please add a field 'filter_version'

  2. Enter '001' as version for all entries

  3. When this datastore parameter is used, set up this 'Plain text' Filter:

    1. [{ "fieldname": 'filter_versie', "filteroperator": 'contains', "filtervalue": '001' }]

Now, when you want to change the list of values, but not impact the current & old requests, follow these steps:

  1. Add '002' in the field 'filter_version'. Do not delete '001' anywhere, as this will affect the older requests.

  2. Open the field in the template-editor, and change the Filter to:

    1. [{ "fieldname": 'filter_versie', "filteroperator": 'contains', "filtervalue": '002' }]

With this solution, you can freely choose which fields need a new set of values.

It is important to do this from setup, because adding it in later requires database-handling from our support team.

Dual filtering

If you want to perform 2 filters at the same time (for example, both a Version filter & a field-specific filter), follow this example:

[{ "fieldname": 'Version', "filtervalue": 'v001' },{"connector": 'and', "fieldname": 'Filter', "filtervalue": 'Q_Exams' }]

In the example above, the list of entries in the datatore parameter is fitlered against 2 rules:

  1. Version = v001

  2. Filter = Q_Exams

Please note that quotes are NOT needed when setting a dynamic value! Quotes are only needed for hardcoded filter values, as in the example above.

When dynamic values are used, this is the correct syntax: [{ "fieldname": 'Version', "filtervalue": 'v001' },{"connector": 'and', "fieldname": 'Filter', "filtervalue": #REPLACE-PARTVALUE-Faculty_promotor||Value# }]

Filtering when the source are the Documents

Filter options

When creating a selection field, for example checkboxes, you have 3 options when settings the Documents filter. These are:

  • No filter: all documents are shown

  • On part: this option allows the filter against 1 (and only 1) document part. For example, where the Category = Test

  • Function: this new feature allows to make a filter against multiple data-elements. The filter is built using Javascript, some example can be found below.

Function (Javascript) Filter examples

Filter against 2 Document parts

In the example below, we only want to show the documents, that are valid under these 2 conditions:

  1. Category 'equals' C1

  2. Docs_Status 'is different from' Archived

So the internal labels of the document parts are : Category & Docs_Status.

This is the Javascript to be used:

var categorypartvalue = document.parts.filter(function (p) { return p.internalname === "Doc_Category"; }).map(function (p) { return p.value; }).join(""); var statuspartvalue = document.parts.filter(function (p) { return p.internalname === "Docs_Status"; }).map(function (p) { return p.value; }).join(""); return categorypartvalue === "C1" && statuspartvalue !== "Archived";

Note: ID a user selected a document in the past, and the user then changes this document's status to 'Archived', the changed document will no longer be shown in the list. This is as expected via the filters. But, the document that was selected in the past is still selected in the DB, but no longer shown.

Filter against current date

The example below checks in filter 1 if the field 'Status' holds 'Beschikbaar' and the field that holds a date in yyyyMMdd, lies after the current date:

return [ { "fieldname": "Status", "filtervalue": "Beschikbaar" }, { "fieldname": "Datum yyyyMMdd", "filteroperator": "greatherthanorequal", "filtervalue": CommonInterface.utcDateToString(new Date(),"yyyyMMdd") } ];

Last updated

Was this helpful?