How to add a fixed filters block to the section
Glossary Item Box
Introduction
Filters are designed to search and filter records in sections. In the bpm'online provided quick, standard and advanced filters and folders. 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 following properties:
- entitySchema – object schema.
- filters – array of added filters.
Assign a reference to the created configuration object to the [fixedFiltersConfig] field of the view model:
this.set("FixedFilterConfig", fixedFilterConfig);
Case description
Add a block of quick filters to the [Contracts] section. Filter by the contract start date and owner.
Case implementation algorithm
1. Create a replacing schema of the [Contracts] section in the custom package.
Create a replacing client module and specify the ContractSectionV2 schema as parent (Fig. 1). 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.
To do this, right-click the [LocalizableStrings] structure node and select [Add] from the context menu (Fig. 2).
Fig. 2. Adding localizable string to the schema
Create two localizable strings with following properties:
Name | Value |
---|---|
OwnerFilterCaption | Owner |
PeriodFilterCaption | Period |
3. Add the implementation of the initFixedFiltersConfig() method to the method collection of the section view model.
Create configuration object with the PeriodFilter and OwnerFilter filter arrays in the initFixedFiltersConfig() method, assign a reference to the created configuration object to the fixedFiltersConfig field of the view model.
The source code of the section view model schema:
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); } } }; });
4. Save the created replacing schema
After saving the schema and restarting the system, a block of fixed filters will appear in the [Contracts] section. These filters will enable to filter contracts by start date and owner (Fig. 3).
Fig. 3. Case result