Skip to main content
Version: 8.1

Example of using the alias mechanism for repeated schema replacement

Level: intermediate

The diff array of modifications has an initial "Name" element with a set of properties. The element is located in the Header container. This schema is replaced several times. The "Name" element is modified and moved freely.

diff: /**SCHEMA_DIFF*/ [
{
/* Insert operation. */
"operation": "insert",
/* The name of the parent element into which to insert the element. */
"parentName": "Header",
/* The name of the parent element property on which to operate. */
"propertyName": "items",
/* The name of the element. */
"name": "Name",
/* The object of element property values. */
"values": {
/* Layout. */
"layout": {
/* Column number. */
"column": 0,
/* The row number. */
"row": 1,
/* The number of combined columns. */
"colSpan": 24
}
}
}
] /**SCHEMA_DIFF*/

In the new version, the element named "Name" has been moved from the SomeContainer element to the ProfileContainer element and must remain there despite the client customization. To enforce this, the element gets a new name "NewName" and the alias configuration object is added to it.

diff: /**SCHEMA_DIFF*/ [
{
/* Insert operation. */
"operation": "insert",
/* The name of the parent element into which to insert the element. */
"parentName": "ProfileContainer",
/* The name of the parent element property on which to operate. */
"propertyName": "items",
/* New name. */
"name": "NewName",
/* The object of element property values​. */
"values": {
/* Bind to the property or function value. */
"bindTo": "Name",
/* Layout. */
"layout": {
/* Column number. */
"column": 0,
/* The row number. */
"row": 0,
/* The number of combined columns. */
"colSpan": 12
}
},

/* alias configuration object. */
"alias": {
/* The old name of the element. */
"name": "Name",
/* An array of custom replacing properties to ignore. */
"excludeProperties": "layout" ],
/* An array of custom replacing operations to ignore. */
"excludeOperations": [ "remove", "move" ]
}
}
] /**SCHEMA_DIFF*/

The new element now has alias. The parent element changed, as is its location on the record page. The excludeProperties property stores a set of properties that will be ignored when the delta is applied, while excludeOperations stores a set of operations that will not be applied to this element from the replacements.

In this example, the layout properties of all "Name" descendants are excluded, and the remove and move operations are also prohibited. This means that the "NewName" element will contain only the root layout property and all properties of the "Name" element from the replacements except Layout. The same applies to operations.

Result for the builder of the diff array of modifications
diff: /**SCHEMA_DIFF*/ [
{
/* Insert operation. */
"operation": "insert",
/* The name of the parent element into which to insert the element. */
"parentName": "ProfileContainer",
/* The name of parent element property on which to operate. */
"propertyName": "items",
/* New name. */
"name": "NewName",
/* The object of element property values. */
"values": {
/* Bind to the property or function value. */
"bindTo": "Name",
/* Layout. */
"layout": {
/* Column number. */
"column": 0,
/* The row number. */
"row": 0,
/*/ The number of combined columns. */
"colSpan": 12
},
}
},
] /**SCHEMA_DIFF*/