The field locking business rule for a record list of a detail

Question

In version 7.7.0.2293 SalesEnterprise + Marketing + CustomerCenter all fields of an editable list record are available for editing. How can I lock some of the fields?

Answer

1) Create a detail via the detail wizard and display several fields on the page tab. Save.

2) Register the detail in the section via the section wizard. Set up columns.

3) To make the detail editable, add dependencies, mixins, attribute and grid merge in the diff property as displayed in the example below:

define("UsrSchema1Detail", ["ConfigurationGrid", "ConfigurationGridGenerator",
"ConfigurationGridUtilities"], function() {
    return {
        entitySchemaName: "UsrTestContactDetail",
        attributes: {
            "IsEditable": {
                dataValueType: Terrasoft.DataValueType.BOOLEAN,
                type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
                value: true
            }
        },
        mixins: {
            ConfigurationGridUtilites: "Terrasoft.ConfigurationGridUtilities"
        },
        details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
        diff: /**SCHEMA_DIFF*/[
            {
            "operation": "merge",
            "name": "DataGrid",
            "values": {
               "className": "Terrasoft.ConfigurationGrid",
               "generator": "ConfigurationGridGenerator.generatePartial",
               "generateControlsConfig": {"bindTo": "generatActiveRowControlsConfig"},
               "changeRow": {"bindTo": "changeRow"},
               "unSelectRow": {"bindTo": "unSelectRow"},
               "onGridClick": {"bindTo": "onGridClick"},
               "activeRowActions": [
                  {
                     "className": "Terrasoft.Button",
                     "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
                     "tag": "save",
                     "markerValue": "save",
                     "imageConfig": {"bindTo": "Resources.Images.SaveIcon"}
                  },
                  {
                     "className": "Terrasoft.Button",
                     "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
                     "tag": "cancel",
                     "markerValue": "cancel",
                     "imageConfig": {"bindTo": "Resources.Images.CancelIcon"}
                  },
                  {
                     "className": "Terrasoft.Button",
                     "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
                     "tag": "remove",
                     "markerValue": "remove",
                     "imageConfig": {"bindTo": "Resources.Images.RemoveIcon"}
                  }
               ],
               "initActiveRowKeyMap": {"bindTo": "initActiveRowKeyMap"},
               "activeRowAction": {"bindTo": "onActiveRowAction"},
               "multiSelect": false
            }
         }
        ]/**SCHEMA_DIFF*/,
        methods: {}
    };
});

5) Descibe the business rule in the detail edit page schema. Make sure you adhere to business rule writing regulations - https://academy.bpmonline.com/documents/technic-sdk/7-12/setting-edit-p…

define("UsrUsrTestContactDetail1Page", ["BusinessRuleModule"], function(BusinessRuleModule) {
    return {
        entitySchemaName: "UsrTestContactDetail",
        details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
        diff: /**SCHEMA_DIFF*/[
            {
                "operation": "insert",
                "name": "UsrContact",
                "values": {
                    "layout": {
                        "colSpan": 12,
                        "rowSpan": 1,
                        "column": 0,
                        "row": 0,
                        "layoutName": "Header"
                    },
                    "bindTo": "UsrContact"
                },
                "parentName": "Header",
                "propertyName": "items",
                "index": 0
            },
            {
                "operation": "insert",
                "name": "UsrTestInt1",
                "values": {
                    "layout": {
                        "colSpan": 12,
                        "rowSpan": 1,
                        "column": 12,
                        "row": 0,
                        "layoutName": "Header"
                    },
                    "bindTo": "UsrTestInt1"
                },
                "parentName": "Header",
                "propertyName": "items",
                "index": 1
            },
            {
                "operation": "insert",
                "name": "UsrTestInt2",
                "values": {
                    "layout": {
                        "colSpan": 12,
                        "rowSpan": 1,
                        "column": 0,
                        "row": 1,
                        "layoutName": "Header"
                    },
                    "bindTo": "UsrTestInt2"
                },
                "parentName": "Header",
                "propertyName": "items",
                "index": 2
            },
            {
                "operation": "insert",
                "name": "CreatedBy",
                "values": {
                    "layout": {
                        "colSpan": 12,
                        "rowSpan": 1,
                        "column": 12,
                        "row": 1,
                        "layoutName": "Header"
                    },
                    "bindTo": "CreatedBy"
                },
                "parentName": "Header",
                "propertyName": "items",
                "index": 3
            }
        ]/**SCHEMA_DIFF*/,
        methods: {},
        rules: {
            "UsrTestInt1": {
                "EnabledUsrTestInt1": {
                    "ruleType": BusinessRuleModule.enums.RuleType.BINDPARAMETER,
                    "property": BusinessRuleModule.enums.Property.ENABLED,
                    "conditions": [
                        {
                            "leftExpression": {
                                "type": BusinessRuleModule.enums.ValueType.CONSTANT,
                                "value": true
                            },
                            comparisonType: Terrasoft.ComparisonType.NOT_EQUAL,
                            rightExpression: {
                                type: BusinessRuleModule.enums.ValueType.CONSTANT,
                                value: true
                            }
                        }
                    ]
                }
            }
        }
    };
});

As a result, the field is locked. If the detail exists but does not have any edit page, you need to either delete the infromation in the SysDetail and SysModuleEdit tables of the detail and recreate it via the detail wizard or create an edit page and register it in the SysModuleEdit  table similarly to the existing ones. Afterwards, write the code necessary for locking fields in the detail edit page schema. 

Like 0

Like

Share

0 comments
Show all comments