Filter editor

From Resco's Wiki
(Redirected from @@filter@@)
Jump to navigation Jump to search

Several Resco tools include a functionality that allows you to define conditions that allow you to filter the records used or displayed in the app. For example:

Overview

These are the main functions of the filter editor:

  • Define conditions, group them with logical operators AND or OR.
  • Define the order of the records.
  • Restrict the maximum number of records.
  • Export or import filters in XML format.

Essentially, filter editor allows users to build database queries or fetches without knowing the syntax of FetchXML.

Example of simple filter editor

Define conditions

Each filter starts with an entity. Without additional configuration, it returns all records of that entity. If you specify a custom sort order, it is also displayed, for example:

account
contact SORT: lastname, firstname

Click Add Condition, select one of the entity fields and a condition operator, for example:

modifiedon This Month

Some operators require additional arguments, for example:

address1_city Equals Prague

Sometimes you need to filter the records of an entity using information from another entity. Click Add Link and select a related entity. Choose the link type as inner or outer join. You can add conditions to this related entity, and also set sort order or restrict the maximum number of returned records. For example, the following view filter shows only those accounts that have an opportunity created within the last 10 days.

Account
Opportunities inner
Created On Last X Days 10

Additionally, you can decide, how your conditions should be evaluated and grouped:

  • AND operator: all grouped conditions must be met
  • OR operator: at least one of the grouped conditions must be met

Unless you specify a different relation between conditions, the implicit operator is AND, i.e., all conditions must be met.

To establish a relation between multiple groups of conditions, use the Group AND and Group OR operators.

Example with multiple linked entities

The following filter for the Bookable Resource Booking links three additional entities. One of them, L1, is explicitly mentioned in the BRB condition group. The two other links are not, but they are still part of the filter, and they are linked by the implicit AND operator. In effect, this filter has three condition groups that all must be met:

  • Bookable Resource Booking
  • Work Order (L0)
  • Resource (L2)

Example of filter editor with multiple linked entities

Define sort order and restrict count

Users usually can modify the sort order in the app, but for example in case of a view, it makes sense to define a valid default sort order. You can also define sort order for related entities that you added via Add Link.

  1. Click Edit Sort to open the Configure Sort Fields window.
  2. Choose the primary column (for example, Name) and the sort order (for example, Ascending).
  3. Click Add if you want to another column for sorting. Click Del to remove it.
  4. Click OK to save your changes.

In some cases, you don't need to find all records, only top five (ordered by a relevant criterion), or even a single one. To restrict the maximum count of records, click Edit Count, enter a value, and then click OK.

Save and share filters

Once you're done editing, click Save or Save & Close.

If you want to reuse the filter in another location, click Export XML to download the filter in XML format (FetchXML). Change to the other location, for example to a different app project, and click Import XML to reuse the filter there.

Data visibility

Occasionally, you may run into a situation that you cannot see a particular record in the app. What are some of the possible causes?

Sync Filters on entities
Find your entity in the Entities section of your app project and click Sync Filter. If a record does not match your Sync Filter, it is not downloaded to the local database, and therefore unavailable in offline mode.
View filters
Edit the view and click Edit Filter. If a record does not match your view filter, it is downloaded to the device, but this particular view does not list it. Different views can have different filters.
Entity Mode (online / offline)
When you create a record in one mode and then switch to the other mode without synchronizing, that record is not visible in the second mode. Synchronize apps when switching between online and offline modes.
Max Sync Records for entity reached
Go to the Configuration section of your app project and switch to the Offline Data Sync tab. The parameter Max Sync Records specifies how many records are downloaded for each object/entity.
User role (profile)
Your user role does not have permission to view the record.
Note It is not possible to use Parent > Child relationships in Sync Filter (Contact.Account is possible, Account.Contacts is not). The same limitation applies to view filters used in online mode.

Using search strings in filters

When app users want to filter the records in a view, they can use only the fields of the viewed entity as filter criteria. For example, on the Opportunity view, you can filter records by Customer or Estimated Revenue, because both are fields of the Opportunity entity. However, you cannot filter for opportunities whose customer comes from a particular city, because City is a field of a different entity, Customer.

Fortunately, there's a way. Using the Edit Filter, you can define a set of conditions that allow full-text search in related fields. In the following example, while on the Opportunity view, app users can use the Search function: the string is then compared with the topic of the opportunity, the name of the account or the full name of the owner (with account and owner being related entities). The filter uses the search condition; when at least one field matches the searched string, the opportunity is displayed. This is ensured by the string @@filter@@ that corresponds to the searched string.

Using search strings in filters

This special behavior is only possible when using the Search function in the app; it does not work for the filter function.

Using search strings in filters is only possible using the Search function in the app

If you use search strings in filters, you have to remove all fields configured for search from the view and add them as a search condition into the filter using @@filter@@ as well. The reason is that the fetch for entity records is constructed from conditions defined in the filter and search fields using AND to group them together. If the conditions are grouped using AND, it will restrict the desired records from being filtered, as it is unlikely that the conditions will be met.

Edit Search window - Configure search field.