Open a Freedom UI page from a custom request handler
To implement the example:
- Set up the page UI. Read more >>>
- Set up how to open the Freedom UI page. Read more >>>
Add an Open Studio homepage button to the custom request page. The button must open the "Studio homepage" page.
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 Requests app.
-
Open the form page.
For this example, open the Requests form page.
-
Add a button.
For this example, add a button that opens the "Studio homepage" page. To do this:
-
Add a Button type component to the toolbar of the Freedom UI Designer.
-
Click and fill out the button property.
Element
Property
Property value
Button that opens the "Studio homepage" page
Title
Open Studio homepage
Style
Focus
-
-
Save the changes.
2. Set up how to open the Freedom UI page
Configure the business logic in the Client Module Designer. For this example, set up how to open the Freedom UI page.
-
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 theHandlerChainService
service that opens pages.AMD module dependencies/* Declare the AMD module. */
define("UsrRequests_FormPage", /**SCHEMA_DEPS*/["@creatio-devkit/common"]/**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ {
return {
...
}
}); -
Set up how to handle the action executed on button click.
- Go to the
viewConfigDiff
schema section →OpenStudioButton
element. - Bind the sending of the custom
usr.OpenStudioHomepageRequest
request to theclicked
button event.
viewConfigDiff schema sectionviewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
/* Button that opens the "Studio homepage" page. */
{
"operation": "insert",
"name": "OpenStudioButton",
"values": {
...,
"clicked": {
/* Bind the sending of the custom request to the "clicked" button event. */
"request": "usr.OpenStudioHomepageRequest"
}
},
...
}
]/**SCHEMA_VIEW_CONFIG_DIFF*/, - Go to the
-
Implement the custom request handler.
- Go to the
handlers
schema section. - Implement the
usr.OpenStudioHomepageRequest
custom request handler. - Retrieve the instance of the HTTP client from
@creatio-devkit/common
. - Send the
crt.OpenPageRequest
base request handler that opens the "Studio homepage" page.
handlers schema sectionhandlers: /**SCHEMA_HANDLERS*/[
{
request: "usr.OpenStudioHomepageRequest",
/* The implementation of the custom request handler. */
handler: async (request, next) => {
/* Retrieve the instance of the HTTP client from "@creatio-devkit/common." */
const handlerChain = sdk.HandlerChainService.instance;
/* Send the base request to open the page. */
await handlerChain.process({
type: 'crt.OpenPageRequest',
schemaName: 'StudioHomePage',
$context: request.$context,
scopes: [...request.scopes]
});
/* Call the next handler if it exists and return its result. */
return next?.handle(request);
}
}
] /**SCHEMA_HANDLERS*/, - Go to the
-
Save the changes.
View the result
- Open the Requests section.
- Create a request.
- Click Open Studio homepage.
As a result, Creatio will open the "Studio homepage" page. View the result >>>
Source code
/* Declare the AMD module. */
define("UsrAppRequests_FormPage", /**SCHEMA_DEPS*/["@creatio-devkit/common"]/**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ {
return {
viewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
/* Button that opens the "Studio homepage" page. */
{
"operation": "insert",
"name": "OpenStudioButton",
"values": {
"type": "crt.Button",
"caption": "#ResourceString(OpenStudioButton_caption)#",
"color": "accent",
"disabled": false,
"clicked": {
/* Bind the sending of the custom request to the "clicked" button event. */
"request": "usr.OpenStudioHomepageRequest"
},
"iconPosition": "only-text"
},
"parentName": "ActionButtonsContainer",
"propertyName": "items",
"index": 3
},
{
"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
}
]/**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": "UsrAppRequests"
}
}
}
}/**SCHEMA_MODEL_CONFIG*/,
handlers: /**SCHEMA_HANDLERS*/[
{
request: "usr.OpenStudioHomepageRequest",
/* The implementation of the custom request handler. */
handler: async (request, next) => {
/* Retrieve the instance of the HTTP client from "@creatio-devkit/common." */
const handlerChain = sdk.HandlerChainService.instance;
/* Send the base request to open the page. */
await handlerChain.process({
type: 'crt.OpenPageRequest',
schemaName: 'StudioHomePage',
$context: request.$context,
scopes: [...request.scopes]
});
/* 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*/
};
});