Implement the conversion of a field value on a page
To implement the example:
- Set up the page UI. Read more >>>
- Set up the field conversion. Read more >>>
Add a converter that converts the Name field value to uppercase on the custom converter page. Display the converted value in the Label type component.
1. Set up the page UI
-
Create an app based on the Records & business processes template. Instructions: Create an app manually (user documentation).
For this example, create a Converters app.
-
Open the form page in the Freedom UI Designer.
For this example, open Converters form page that includes the Name field out of the box.
-
Add a label.
For this example, add a label that contains the converted value of the Name field.
To do this:
-
Add a label to the working area of the Freedom UI Designer.
-
Click and fill out the label properties.
Element
Property
Property value
Label that contains the converted value of a username
Text
Converted value of a username
Style
Body
-
-
Save the changes.
2. Set up the field conversion
Configure the business logic in the Client Module Designer. For this example, set up the field value conversion.
-
Open the source code of the Freedom UI page. To do this, click .
-
Implement a converter.
- Go to the
converters
schema section. - Implement a
usr.ToUpperCase
custom converter that converts the value to uppercase.
converters schema sectionconverters: /**SCHEMA_CONVERTERS*/{
/* Implement a custom converter that converts the value to uppercase. */
"usr.ToUpperCase": function(value) {
return value?.toUpperCase() ?? '';
}
}/**SCHEMA_CONVERTERS*/, - Go to the
-
Bind an attribute to the label.
- Go to the
viewConfigDiff
schema section →UsrName
element. - Add an
UsrName
attribute to thecaption
property. - Bind the
usr.ToUpperCase
converter to the$UsrName
attribute.
viewConfigDiff schema sectionviewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
...,
/* Label that contains the converted value of a username. */
{
"operation": "insert",
"name": "UsrLabel",
"values": {
...,
/* Bind the "usr.ToUpperCase" converter to the "$UsrName" attribute. */
"caption": "$UsrName | usr.ToUpperCase",
...,
},
...
}
]/**SCHEMA_VIEW_CONFIG_DIFF*/, - Go to the
-
Save the changes.
View the result
- Open the Requests section.
- Create a request that has an arbitrary name. For example, "Converter's name."
As a result, Creatio will convert the Name field value to uppercase and display it in the Label type component. View the result >>>
Source code
/* Declare the AMD module. */
define("UsrAppConverters_FormPage", /**SCHEMA_DEPS*/[]/**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/()/**SCHEMA_ARGS*/ {
return {
viewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
{
"operation": "insert",
"name": "UsrName",
"values": {
"layoutConfig": {
"column": 1,
"row": 1,
"colSpan": 1,
"rowSpan": 1
},
"type": "crt.Input",
"label": "$Resources.Strings.UsrName",
"control": "$UsrName"
},
"parentName": "LeftAreaProfileContainer",
"propertyName": "items",
"index": 0
},
/* Label that contains the converted value of a username. */
{
"operation": "insert",
"name": "Label",
"values": {
"layoutConfig": {
"column": 1,
"row": 2,
"colSpan": 1,
"rowSpan": 1
},
"type": "crt.Label",
/* Bind the "usr.ToUpperCase" converter to the "$UsrName" attribute. */
"caption": "$UsrName | usr.ToUpperCase",
"labelType": "headline",
"labelThickness": "normal",
"labelEllipsis": false,
"labelColor": "#181818",
"labelBackgroundColor": "transparent",
"labelTextAlign": "start"
},
"parentName": "LeftAreaProfileContainer",
"propertyName": "items",
"index": 1
}
]/**SCHEMA_VIEW_CONFIG_DIFF*/,
viewModelConfig: /**SCHEMA_VIEW_MODEL_CONFIG*/{
"attributes": {
"UsrName": {
"modelConfig": {
"path": "PDS.UsrName"
}
},
"Id": {
"modelConfig": {
"path": "PDS.Id"
}
}
}
}/**SCHEMA_VIEW_MODEL_CONFIG*/,
modelConfig: /**SCHEMA_MODEL_CONFIG*/{
"dataSources": {
"PDS": {
"type": "crt.EntityDataSource",
"config": {
"entitySchemaName": "UsrAppConverters"
}
}
}
}/**SCHEMA_MODEL_CONFIG*/,
handlers: /**SCHEMA_HANDLERS*/[]/**SCHEMA_HANDLERS*/,
converters: /**SCHEMA_CONVERTERS*/{
/* Implement a custom converter that converts the value to uppercase. */
"usr.ToUpperCase": function(value) {
return value?.toUpperCase() ?? '';
}
}/**SCHEMA_CONVERTERS*/,
validators: /**SCHEMA_VALIDATORS*/{}/**SCHEMA_VALIDATORS*/
};
});