Adding quick filter block to a section
Glossary Item Box
Introduction
Filters are designed to search and filter records in sections. In bpm'online quick, standard and advanced filters and folders are provided. More information can be found in the "Filters” article.
To add a block of quick filters to the section, override the initFixedFiltersConfig() method in the replacement schema, create the fixedFilterConfig configuration object in this method with the following properties:
- entitySchema – object schema.
- filters – array of added filters.
Assign a reference to the created configuration object to the fixedFiltersConfig view model attribute:
this.set("FixedFilterConfig", fixedFilterConfig);
Case description
Add a block of quick filters to the [Contracts] section. Filter by the contract start date and owner.
Source code
You can download the package with case implementation using the following link.
Case implementation algorithm
1. Create a replacing schema of the [Contracts] section in the custom package.
Create a replacing custom module and populate its properties with (Fig.1):
- [Parent object] – “Page schema – “Contracts” section”;
- [Name] – ContractSectionV2.
The procedure for creating a replacing client schema is covered in the “Creating a custom client module schema” article.
Fig. 1. Properties of the [Contracts] section replacing schema
2. Add localizable strings to the schema structure.
Create two new localizable strings (Fig.2) with the following properties:
Name | Value |
---|---|
OwnerFilterCaption | Owner |
PeriodFilterCaption | Period |
Fig. 2. Adding localizable string to the schema
3. Add the implementation of the initFixedFiltersConfig() method to the method collection of the section view model.
Create a configuration object with the PeriodFilter and OwnerFilter filter arrays in the initFixedFiltersConfig() method, assign a reference to the created configuration object to the fixedFiltersConfig view model attribute .
The replacing schema source code is as follows:
define("ContractSectionV2", ["BaseFiltersGenerateModule"], function(BaseFiltersGenerateModule) { return { // Name of the section schema entitySchemaName: "Contract", // Method collection of the section view model. methods: { // Initializes the fixed filters. initFixedFiltersConfig: function() { // Creating a Configuration Object. var fixedFilterConfig = { // The schema of the section object is specified as an object schema for fixed filters. entitySchema: this.entitySchema, // Array of filters. filters: [ // Start period filter. { // The name of the filter. name: "PeriodFilter", // Filter header. caption: this.get("Resources.Strings.PeriodFilterCaption"), // The data type – date. dataValueType: this.Terrasoft.DataValueType.DATE, // Start date of the filtering period. startDate: { // Filter the data from the [Date] column. columnName: "StartDate", // Default value. defValue: this.Terrasoft.startOfWeek(new Date()) }, // Date of the filtering period completion. dueDate: { columnName: "StartDate", defValue: this.Terrasoft.endOfWeek(new Date()) } }, // Owner filter. { // The name of the filter. name: "Owner", // Filter header. caption: this.get("Resources.Strings.OwnerFilterCaption"), // Filter the data from the [Owner] column. columnName: "Owner", // Current user contact is specified as default value. // Value is received from the system setting. defValue: this.Terrasoft.SysValue.CURRENT_USER_CONTACT, // The data type – lookup. dataValueType: this.Terrasoft.DataValueType.LOOKUP, // Filter. filter: BaseFiltersGenerateModule.OwnerFilter } ] }; // A link to the configurational object is assigned to the [FixedFilterConfig] column. this.set("FixedFilterConfig", fixedFilterConfig); } } }; });
After saving the schema and restarting the system, a block of fixed filters will appear in the [Contracts] section. These filters will enable you to filter contracts by start date and owner (Fig. 3).
Fig. 3. Case result