Adding the [FILTRATION] rule to the edit page
Glossary Item Box
Example of adding the [FILTRATION] rule to the edit page
Case description
Add the [State/province] and [City] field to the contact page. When selecting a specific region, a list of cities must be filtered by the selected region. When selecting a specific city, the region field must be filled with the corresponding region.
Case implementation algorithm
1. Create a replacement contact edit page
A replacement client module must be created; [Display schema – Contact card] (Fig. 1) must be specified as the parent object.
The process of creating a replacement page is described in the article Creating a custom client module schema.
Fig. 1. — Properties of the replacement edit page
2. Add a configuration object with settings of the page field location to the diff array
Locate the [City] and [State/province] fields on the contact edit page.
For this purpose, add the program code of the replacement module of the page to the source code tab.
// Add the BusinessRuleModule module to the list of module rules. define("ContactPageV2", ["BusinessRuleModule", "ConfigurationConstants"], function(BusinessRuleModule, ConfigurationConstants) { return { // Schema name of the edit page object. entitySchemaName: "Contact", // Visualization setup for the [City] and [State/provicne] fields on the edit page. diff: [ // Metadata for adding the [City] field. { "operation": "insert", "parentName": "ContactGeneralInfoBlock", "propertyName": "items", "name": "City", "values": { "layout": {"column": 13, "row": 2, "colSpan": 12} } }, // Metadata for adding the [State/province] field. { "operation": "insert", "parentName": "ContactGeneralInfoBlock", "propertyName": "items", "name": "Region", "values": { "layout": {"column": 0, "row": 2, "colSpan": 12} } } ] }; });
3. Add the rule with the FILTRATION type for the [City] column to the rules property of the page view model
define("ContactPageV2", ["BusinessRuleModule", "ConfigurationConstants"], function(BusinessRuleModule, ConfigurationConstants) { return { entitySchemaName: "Contact", // Visualization setup for the [City] and [State/provicne] fields on the edit page. diff: [ // Metadata for adding the [City] field. // Metadata for adding the [State/provicne] field. ], // Rule object for the edit page view model. rules: { // The set of rules for the [City] column of the view model. "City": { // Rules for filtering the [City] column by the [Region] column. FiltrationCityByRegion: { /// FILTRATION rule type. ruleType: BusinessRuleModule.enums.RuleType.FILTRATION, // Reverse filtering will be performed. autocomplete: true, autoClean: true, // Path to the column in the [City] reference shema, // which the [City] column of the page view model is referencing. baseAttributePatch: "Region", // Type of the comparison operation in filter. comparisonType: Terrasoft.ComparisonType.EQUAL, // The view model column (attribute) is used as the value // during the comparison. type: BusinessRuleModule.enums.ValueType.ATTRIBUTE, // Name of the page view model column, // by which the filtering will be performed. attribute: "Region" } } } }; });
4. Save the created replacement page schema
When the schema is saved and the web-page of the system is updated on the contact edit page, two new fields [State/province] and [City] will appear. The content will be filtered in each of them depending on the value selected in another field (Fig. 2).
Fig. 2. – Demonstrating the case implementation result