Dynamic filter values
In addition to static filter values, ADITO allows client users to work with
dynamic filter values. Dynamic values are retrieved through a Provider whose
filterVariablesProcess contains the core logic.
var res = {
// key : display value
"$xxx.yyy.myId": translate.text("${FILTER_DYNAMIC_VALUE_xxx}")
};
result.object(res);
Example
The xRM project contains a typical example in ActivityFilter_view. In the
filter component, users can filter by Responsible. In the Value combo box,
they can select Employee records and the value me. The value is dynamic
because it depends on the currently logged-in ADITO user.
Figure: Example of the dynamic filter value
me in context Activity.
Configuration
EntityField RESPONSIBLE of Activity_entity in module
activity
has a Consumer Employees, which depends on Provider Employees of
Employee_entity in module
usermanagement.
The core logic is implemented in the Provider property filterVariablesProcess:
var res = {
"$global.user.contactId": translate.text("${FILTER_DYNAMIC_VALUE_ME}")
};
result.object(res);
Figure: Employee_entity.Employees.filterVariablesProcess.
How to use filterVariablesProcess
The result of filterVariablesProcess can contain any number of key-value
pairs:
- The key is the variable whose value should be used.
- The value is the display value shown in the client.
In the example above, the client shows me as an additional filter value. If
the user selects it, ADITO uses the value of $global.user.contactId as the
actual filter value.
Universal usability
This principle can be used with any $global and $sys variable. If required,
additional $sys variables can be provided by ADITO development. You can also
define your own $global variables in autostartNeon by using
vars.set("$global.xxx.yyy", variableValue).
Technical background
This feature is implemented on the Provider side because a Provider can define
a lookupIdField and therefore use an identifier other than the default UID.
Dynamic filters must also be able to work with those alternative values.
For example, if the Provider uses the default UID, a dynamic filter value such
as my company requires the CONTACTID of the user's company. If the Provider
uses a lookupIdField such as ORGANISATIONID, the same dynamic filter value
requires the ORGANISATIONID of the user's company.