Creatio development guide
PDF
This documentation is valid for Creatio version 7.15.0. We recommend using the newest version of Creatio documentation.

Locking edit page fields

Glossary Item Box

Introduction

During the development of the Creatio custom functions, you may need to lock all fields and details on an edit page under certain conditions. The mechanism of locking edit page fields lets you implement page business logic without creating additional business rules.

ATTENTION

The locking mechanism is available in version 7.11.1 and up.

ATTENTION

You can disable the locking of edit page fields using the CompleteCardLockout option on the Feature Toggle page (see “Feature Toggle. Mechanism of enabling and disabling functions”). The Feature Toggle page is available via the following URL: ../0/Nui/ViewModule.aspx#BaseSchemaModuleV2/FeaturesPage. For example, https://myserver.com/CreatioWebApp/0/Nui/ViewModule.aspx#BaseSchemaModuleV2/FeaturesPage

As a result of applying the locking mechanism on an edit page, all fields and details will become locked. If the field has a binding for the enabled property in the diff array element or the business rule, the mechanism will not lock this field. Locking a detail will hide buttons and menu items for performing operations with the detail records. A locked detail with an editable list will still feature an ability to access the object page, however, all fields on it will be locked.

ATTENTION

The locking mechanism is intended for locking details with a regular list and an editable list. To ensure the correct operation of the mechanism for details with editable fields, create a replacement schema for this detail and control the availability of fields using the IsEnabled attribute.

To enable the locking mechanism, set the source code of the edit page to false for the IsModelItemsEnabled model attribute:

this.set(“IsModelItemsEnabled”, false);

Alternatively, set the default value for the attribute:

"IsModelItemsEnabled": {
    dataValueType: Terrasoft.DataValueType.BOOLEAN,
    value: true,
    dependencies: [{
        columns: ["PaymentStatus"],
        methodName: "setCardLockoutStatus"
    }]
}

Additionally, to operate the locking mechanism on a specific edit page in the diff array of this page, specify the DisableControlsGenerator generator for the containers in which you want to lock fields. Therefore, to lock all fields of an edit page, specify the global CardContentWrapper container:

diff: /**SCHEMA_DIFF*/[
    {
        "operation": "merge",
        "name": "CardContentWrapper",
        "values": {
            "generator": "DisableControlsGenerator.generatePartial"
        }
    }
]/**SCHEMA_DIFF*/

ATTENTION

In versions 7.13.0 and below, an attempt to specify a generator value will trigger an error when opening the edit page in the Section Wizard.

To fix the error:

  1. Find out the name of the group containing all employees. To do this, use the following DB query.
    select Name from SysAdminUnit
    
  2. Run the script provided below on your database. Note that the @allEmpoyeeGroupName field must be filled in with the name of the group containing all employees of your organization.
    DECLARE @allEmpoyeeGroupName nvarchar(max) = 'All employees';
    DECLARE @featureName nvarchar(max) = 'PageDesignerCustomGeneratorFix'
    DECLARE @featureStatus bit = 1;
    
    IF (NOT EXISTS (SELECT NULL FROM Feature WHERE Code = @featureName))
    BEGIN
      INSERT INTO Feature (Name, Description, Code, ProcessListeners) 
      VALUES (@featureName, @featureName, @featureName, 0)
    END
    IF(EXISTS (SELECT NULL FROM AdminUnitFeatureState 
             WHERE FeatureId = (SELECT Id FROM Feature WHERE Code = @featureName) AND
               SysAdminUnitId = (SELECT Id FROM SysAdminUnit WHERE Name = @allEmpoyeeGroupName)) )
    BEGIN
      UPDATE AdminUnitFeatureState SET FeatureState = @featureStatus WHERE FeatureId = (SELECT Id FROM Feature WHERE Code = @featureName) AND
                                  SysAdminUnitId = (SELECT Id FROM SysAdminUnit WHERE Name = @allEmpoyeeGroupName)
    END
    ELSE
    BEGIN
      INSERT INTO AdminUnitFeatureState (ProcessListeners, SysAdminUnitId, FeatureState, FeatureId) VALUES 
                        (
                        0,
                        (SELECT Id FROM SysAdminUnit WHERE Name = @allEmpoyeeGroupName),
                        @featureStatus, 
                        (SELECT Id FROM Feature WHERE Code = @featureName)
                         )
    END
    
    The script introduces an extra feature into the system, PageDesignerCustomGeneratorFix, and enables it for the “All employees” user group.
  3. Examine the generateCustomItem() method in the ViewModelSchemaDesignerViewGenerator module. The method must look like this:

    generateCustomItem: function(config) {
        if (Terrasoft.Features.getIsEnabled("PageDesignerCustomGeneratorFix")) {
            if (config) {
                delete config.generator;
            }
            return this.generateStandardItem(config);
        } else {
            return this.generateLabel({
                caption: config.name
            });
        }
    }
    

    NOTE

    If the generateCustomItem() method is different from the one specified above, you must replace the ViewModelSchemaDesignerViewGenerator class and change the generateCustomItem() method.

  4. On the newly added FeaturesPage, check the value of the PageDesignerCustomGeneratorFix setting. When the mouse pointer hovers on , a notification [The feature has enabled state for the group of the users] must pop up.

    Fig. 1. – Notification popup

Locking exceptions

It is possible to disable locking for some fields and details. To do this, override the getDisableExclusionsDetailSchemaNames() and getDisableExclusionsColumnTags() methods. These methods return lists of fields and details that should not be blocked by the mechanism. The implementation of methods is available below:

getDisableExclusionsColumnTags: function() {
    return ["SomeField"];
}
getDisableExclusionsDetailSchemaNames: function() {
    return ["SomeDetailV2"]
}

More complex exception logic can be implemented by overriding the isModelItemEnabled() method for fields and the isDetailEnabled() method for details. These methods are called for each field and detail. They receive the name and return the availability signal of the field or detail. The implementation of methods is available below:

isModelItemEnabled: function(fieldName) {
    var condition = this.get("SomeConditionAttribute");
    if (fieldName === "ExampleField" || condition)) {
        return true;
    }
    return this.callParent(arguments);
}

isDetailEnabled: function(detailName) {   
    if (detailName === "ExampleDetail") {
        var exampleDate = this.get("Date");
        var dateNow = new Date(this.Ext.Date.now());
        var condition = this.Ext.Date.isDate(exampleDate) && exampleDate >= dateNow;
        return condition;
    }
    return this.callParent(arguments);
}
© Creatio 2002-2020.

Did you find this information useful?

How can we improve it?