Filters

In several parts of the blueprint filters can be used. A filter is an exact definition of a subset of records in a certain class: like all persons younger than 18 years. Or all persons living in Melbourne.

In general filters are used either to search for data in the database, or to control the bussines logic of the application, but they can also be used to control the user interface of the application.

Some of the uses of filters are:

  • To find a table of records when searching on a class.
  • To control the appearance of fields. Fields that are not relevant in a certain context can be hidden.
  • To define the read, insert, update or delete permissions of classes or fields for certain user groups.
  • To define for what records a certain section would be displayed.
  • To control when triggers fire, scripts are executed or helpers are used.

A filter is always related to one main class in the blueprint. In the nodes of the filter, fields from related classes can be used as defined in the data model.

 

Creating filters

Filters can be created in the blueprint, after which they can be used in many different places. When creating a filter, a name is required, aswell as the class this filter is applied to. A filter is always related to one class in the blueprint.

In the details view of a filter, the terms of the filter can be constructed. This is done by adding filter items. A newly created filter already contains a single empty item. In an item, either a boolean operator (and, or, not), or a field route can be chosen. These field routes can lead to fields of the class being filtered or fields of any related classes.

In the case a field route is selected, a filter operator such as "equals to", "<" or "=" can be selected. Take note that the operators shown depend on the data type of the field being filtered. When an operator is selected, a value can be given to compare the selected field to.

In the case a boolean operator is selected, children can be added to this item. If the 'and' operator is selected, records must match all the filter items that are added as children to the 'and' item. If 'or' is selected the record would only have to match one of this item's children. Now when we change it to "not", the search will return all the records that do not match the child filter. A "not" item can only have one child item.

Below is an example of a filter definition in the blueprint, if the records' total gross amount is larger than 1000, and either the order has been paid or the shipping date is earlier than today, the record matches the filter:

When ready, the filter can be tested. Testing a filter displays the results of the filter, these can be checked to see if the filter is working as intended.

 

 For more info about searching and queries go to: Queries: Advanced search