Hide a feature at the development stage on a page
To implement the example:
- Set up the page UI. Read more >>>
- Hide the feature at the development stage. Read more >>>
1. Set up the page UI
-
Add custom feature at the development stage.
-
Open the Feature toggling section. Instructions: Open the Feature toggling page.
-
Click New and fill out the feature properties.
Property
Property value
Feature code
UsrShowMyButton
-
Save the changes.
-
-
Create an app based on the Records & business processes template. Instructions: Create an app manually (user documentation).
For this example, create a Requests app.
-
Open the form page in the Freedom UI Designer.
For this example, open the Requests form page.
-
Add a button.
For this example, add a button that contains the feature at the development stage.
To do this:
-
Add a Button type component to the toolbar of the Freedom UI Designer.
-
Click
and fill out the button properties.
Element
Property
Property value
Button that contains the feature at the development stage
Title
Feature
Style
Primary
-
-
Save the changes.
2. Hide the feature at the development stage
Configure the business logic in the Client Module Designer. For this example, hide the feature at the development stage.
-
Open the source code of the Freedom UI page. To do this, click
.
-
Add the dependencies. To do this, add
@creatio-devkit/common
library as a dependency. The library includes theFeatureService
service to check the feature status.AMD module dependencies/* Declare the AMD module. */
define("UsrRequests_FormPage", /**SCHEMA_DEPS*/["@creatio-devkit/common"] /**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ {
return {
...
}
}); -
Add an attribute.
- Go to the
viewModelConfig
schema section →attributes
configuration object. - Add an
IsFeatureDeveloped
attribute that stores data about the feature status.
viewModelConfig schema sectionviewModelConfig: /**SCHEMA_VIEW_MODEL_CONFIG*/{
"attributes": {
...,
/* The attribute that stores data about the feature status. */
"IsFeatureDeveloped": {}
},
...
}/**SCHEMA_VIEW_MODEL_CONFIG*/, - Go to the
-
Bind an attribute to the field.
- Go to the
viewConfigDiff
schema section →UsrFeatureButton
element. - Bind the
IsFeatureDeveloped
attribute to thevisible
property.
viewConfigDiff schema sectionviewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
...,
/* Button that contains the feature at the development stage. */
{
"operation": "insert",
"name": "UsrFeatureButton",
"values": {
...,
/* The property that flags the button as visible. Bound to the "IsFeatureDeveloped" attribute. */
"visible": "$IsFeatureDeveloped"
},
...
}
]/**SCHEMA_VIEW_CONFIG_DIFF*/, - Go to the
-
Implement the base request handler.
-
Go to the
handlers
schema section. -
Add a custom implementation of the
crt.HandleViewModelInitRequest
base request handler.- Create an instance of the service that checks the feature status from
@creatio-devkit/common
. - Retrieve the status of the feature that has the
UsrShowMyButton
code and specify the status in theIsFeatureDeveloped
attribute.
- Create an instance of the service that checks the feature status from
handlers schema sectionhandlers: /**SCHEMA_HANDLERS*/[
{
request: "crt.HandleViewModelInitRequest",
/* The custom implementation of the system request handler. */
handler: async (request, next) => {
/* Create an instance of the service that checks the feature status from "@creatio-devkit/common." */
const featureService = new sdk.FeatureService();
/* Retrieve the status of the feature that has the "UsrShowMyButton" code and specify the status in the "IsFeatureDeveloped" attribute. */
request.$context.IsFeatureDeveloped = await featureService.getFeatureState('UsrShowMyButton');
/* Call the next handler if it exists and return its result. */
return next?.handle(request);
},
},
] /**SCHEMA_HANDLERS*/, -
-
Save the changes.
View the result
To view the outcome of the example for the feature at the development stage:
- Open the Requests section.
- Create a request.
As a result, Creatio will hide a Feature button that contains the feature at the development stage from the custom request page. View the result >>>
To view the outcome of the example for the fully developed feature:
- Turn on the "UsrShowMyButton" additional feature. Instructions: Change the status of an additional feature for all users.
- Open the Requests section.
- Create a request.
As a result, Creatio will display a Feature button that contains the fully developed feature on the custom request page. View the result >>>
Source code
/* Declare the AMD module. */
define("UsrRequests_FormPage", /**SCHEMA_DEPS*/["@creatio-devkit/common"] /**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ {
return {
viewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
/* Button that contains the feature at the development stage. */
{
"operation": "insert",
"name": "UsrFeatureButton",
"values": {
"type": "crt.Button",
"caption": "#ResourceString(UsrFeatureButton_caption)#",
"color": "primary",
"disabled": false,
/* The property that flags the button as visible. Bound to the "IsFeatureDeveloped" attribute. */
"visible": "$IsFeatureDeveloped"
},
"parentName": "ActionButtonsContainer",
"propertyName": "items",
"index": 3
}
]/**SCHEMA_VIEW_CONFIG_DIFF*/,
viewModelConfig: /**SCHEMA_VIEW_MODEL_CONFIG*/{
"attributes": {
"Id": {
"modelConfig": {
"path": "PDS.Id"
}
},
/* The attribute that stores data about the feature status. */
"IsFeatureDeveloped": {}
}
}/**SCHEMA_VIEW_MODEL_CONFIG*/,
modelConfig: /**SCHEMA_MODEL_CONFIG*/{
"dataSources": {
"PDS": {
"type": "crt.EntityDataSource",
"config": {
"entitySchemaName": "UsrRequests"
}
}
}
}/**SCHEMA_MODEL_CONFIG*/,
handlers: /**SCHEMA_HANDLERS*/[
{
request: "crt.HandleViewModelInitRequest",
/* The custom implementation of the system request handler. */
handler: async (request, next) => {
/* Create an instance of the service that checks the feature status from "@creatio-devkit/common." */
const featureService = new sdk.FeatureService();
/* Retrieve the status of the feature that has the "UsrShowMyButton" code and specify the status in the "IsFeatureDeveloped" attribute. */
request.$context.IsFeatureDeveloped = await featureService.getFeatureState('UsrShowMyButton');
/* Call the next handler if it exists and return its result. */
return next?.handle(request);
},
},
] /**SCHEMA_HANDLERS*/,
converters: /**SCHEMA_CONVERTERS*/{}/**SCHEMA_CONVERTERS*/,
validators: /**SCHEMA_VALIDATORS*/{}/**SCHEMA_VALIDATORS*/
};
});