FILTERS
Filters
and make filters
blocks are used to work with drop-down lists and allow to change the value of the field of non-primitive type conditionally. For instance, you have a Select Field with choices: Fruits and Vegetables. After you take Fruits, the list of available fruits will be rendered inside a Lookup Field. If you chose Vegetables, the list of vegetables would be shown.
Creating a Filter Action
OnFieldFilter Action is available only for non-primitive Data Types (Select Fields primarily).
You have two options to create onFieldFilter action:
Expand Field menu inside the Data Type on the right of Field’s panel and click “Create on field filtered event”. You will be redirected to the created block
Inside the Web Page View click on created Select Field, and inside Properties -> Actions select “On field filtered”
Filters
Filters
block is used to specify the Select Field that will be filtered.
The following block specifies the return type of filters - Income/Expense Category
so the App Builder knows that some filter conditions would be applied to that field.
It is possible to use filters
block in custom functions, too:
Make filters
make filters
block uses Data Type specified above with filters
block and applies the conditions, that would be applied to the final drop-down list.
The following block makes a filter named category for “Income/Expense Category” Data Type and returns only those elements, that are equal to a chosen by the user item.Type. If we have two Types (Income and Expense) of “Income and Expense tracker”, and the user chooses Expense Type, then inside the “Income/Expense Category” Lookup Field only elements with Type equal to Expense will be shown.
Examples:
It’s considered a bad practice to write filter conditions inside the onFieldFiltered
function.
Here we improved the code above. We created a new function named “Filter for Income/Expense Category” with a parameter “transaction type”.
After that, we can call the function from the onFieldFiltered
block and pass the corresponding parameters.
If you don’t need the parameters, for instance, you have a boolean value to compare with, make filters
block would be helpful, too.
In the next example, we have a Currency Data Type with a lot of available currencies. But only some of them are used in your country. We mark them as “In use”. The code below will show only currencies marked as “In use” inside the dropdown Currency, instead of 50 or more different currencies, unavailable in your country.