This guide will demonstrate how to filter the list of items displayed in a drop-down menu.
[!success]- Prerequisites for further work
To follow along, you must meet the following prerequisites:
- Running database server
- Running ORIGAM Server
- Project created in ORIGAM Architect
- Entities and fields created
- Lookups created
- User screens created
- Running client application in your browser
Once these prerequisites are set up, log into the client application using the username and password you created during the project setup.
In certain cases, you may need to filter the items in your drop-down menu to display a specific selection of records.
For instance, in a Task Manager application, you need to assign tasks to responsible individuals using a drop-down menu in a field named Assigned to
. However, there are by default some system accounts visible in the menu that you need to filter out:
To achieve this, you’ll work with Filters, Filter Sets, Data Structures, and Lookups.
Filters
Filters are defined at the level of database Entities and are used in Filter Sets.
Default Filters
There are several default Filters already defined in the default ORIGAM model. For example, Users are located in the Business Partner
entity under the Partner Management
folder, and they come with the following default Filters:
Custom Filters
To create your own Filters, follow this procedure:
Create a new Filter
In the Model Browser, go to Data / Entities, under the package folder of your application, right-click on the Entity for which you want to create the Filter and select New / Filter:
In the Filter details, name the Filter (e.g.,):
Save it.
Add Function(s)
In the Model Browser, right-click on the Filter you just created and select New / Function Call:
Configure Function(s)
In the Function Call properties, provide the Name
and select the Function
you want to use:
Save it, and expand the Function Call you just created in the Model Browser:
Next, set up the Left and Right parts of the filter condition using different options:
For example, to filter Tasks after the deadline or with a deadline today, set up the following Filter using a system Parameter named parCurrentDate
:
Alternatively, to filter out system Users (those with no email set), use the following Filter:
More details on Filters can be found here.
Filter Sets
Filter Sets are based on Entity Filters, defined in Data Structures, and are used in Lookups when loading data.
To create a Filter Set for a drop-down menu, follow this procedure:
Create a new Filter Set
In the Model Browser, go to Data / Data Structures, under the package folder of your application, right-click on the Lookup Data Structure
for which you want to create a Filter Set and select New / Filter Set:
Remember to create the Filter Set for the Data Structure used in the Lookup you want to use in your drop-down menu. Such Data Structure names follow our naming convention and start with
Lookup
, e.g.,LookupTask_Name_GetId
.
Name your Filter Set
In the Filter Set properties, name your set using the naming convention GetBy
+ parameter, e.g.:
Save it.
Add Filter(s)
Right-click on your Filter Set and select New / Filter:
Configure Filter(s)
In the Filter Set Filter details, select your Entity
and Filter
, and the Name
will be created automatically. For example:
Save it, and your Filter Set will be ready to use.
Lookup settings
When defining a Filter Set in Lookup Data Structures, you need to configure them in the Lookup details using the ListMethod
property. If the Filter Set is properly configured in the Lookup Data Structure, you can select it here. For example:
Save it, and now your Lookup will display only items based on your Filter Set settings.
Identifying the Data Structure
In some cases, you may not be sure which Data Structure you need to create a Filter Set for. To choose the correct Data Structure, follow these steps:
Open the Screen
In the Model Browser, go to User Interface / Screens, under the package folder of your application, double-click on the Screen name where the drop-down menu you want to work with is located.
Select the Screen Section
In the Screen editor, select the Screen Section where the drop-down menu you want to edit is located. If there is only one Screen Section in your Screen, the entire block may look like this:
View the Properties
Then, in the right bar of the Architect, switch to the Properties tab:
Open the Screen Section
In the Screen Section Properties, double-click on the icon next to the Screen Section (Panel
) name:
This will open the right Screen Section for editing.
Open the Lookup
Next, in the right bar, go to the Field Properties tab and double-click on the icon next to the DataLookup
name:
Open the Data Structure
In the Lookup properties, double-click on the icon next to the ListDataStructure
name:
Verify the Data Structure
Now you can confirm that you are editing the correct Data Structure used in the drop-down menu you want to edit. This Data Structure, for example, has the following Filter Sets defined:
For instance, the Filter Set named UsersOnly
is defined to filter out system Users with no email set using the Entity Filter named GetUsersWithEmail
that we have already shown: