Open a page from a custom request handler
@creatio-devkit/common
includes the HttpClientService
service that opens pages. Both Freedom UI and Classic UI open record pages in a similar way. When Creatio adds a record, you can pass the needed default field values.
Open a Freedom UI page from a custom request handler
Detailed example: Open a Freedom UI page from a custom request handler.
To open a Freedom UI page from a custom request handler:
-
Add a button to open a Freedom UI page if needed. Instructions: Set up Button components (user documentation).
-
Add the dependencies. Instructions: Display the value of a system variable (similarly to step 2). Instead of the
SysValuesService
service, use theHttpClientService
service that sends HTTP requests. -
Set up how to handle the action executed on button click.
- Go to the
viewConfigDiff
schema section → select required element. For example,SomeButton
. - Bind the sending of the custom
usr.SomeCustomRequest
request to the element event.
viewConfigDiff schema sectionviewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
/* Button that opens the page. */
{
"operation": "insert",
"name": "SomeButton",
"values": {
...,
"clicked": {
/* Bind the sending of the custom request to the "clicked" button event. */
"request": "usr.SomeCustomRequest"
}
},
...
},
...
]/**SCHEMA_VIEW_CONFIG_DIFF*/, - Go to the
-
Implement the custom request handler.
-
Go to the
handlers
schema section. -
Implement the
usr.SomeCustomRequest
custom request handler.- Retrieve the instance of the HTTP client from
@creatio-devkit/common
. - Send the
crt.OpenPageRequest
base request handler that opens the page.
View an example of a
usr.SomeCustomRequest
request handler that sends thecrt.OpenPageRequest
request handler below. Thecrt.OpenPageRequest
request handler opens the Some page page of theSomePageSchema
schema.handlers schema sectionhandlers: /**SCHEMA_HANDLERS*/[
{
request: "usr.SomeCustomRequest",
/* 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 handler to open the "Some page" page of the "SomePageSchema" schema. */
await handlerChain.process({
type: 'crt.OpenPageRequest',
schemaName: 'SomePageSchema',
$context: request.$context,
scopes: [...request.scopes]
});
/* Call the next handler if it exists and return its result. */
return next?.handle(request);
}
}
] /**SCHEMA_HANDLERS*/, - Retrieve the instance of the HTTP client from
-
Open a specific typified Freedom UI page from a base request handler
This functionality is available for Creatio 8.0.10 and later.
If you use different typified pages for a single section, the button that adds records displays as many options as the number of typified pages you set up. Since version 8.0.10, Creatio lets you set up the button to create records of a specific type only. In this case, the button displays no options and interacts with only one typified page.
Detailed example: Create records of a specific type using typified Freedom UI page.
To create records of a specific type only using a typified Freedom UI page:
-
Set up typified app pages for adding records id needed. Instructions: Set up typified app pages (user documentation).
-
Add a button that adds a new record using typified Freedom UI pages to the list page if needed. Instructions: Set up Button components (user documentation).
-
Select the page field that determines the record type you can create.
- Select the button added on the previous step on the working area of the Freedom UI Designer. This opens the element setup menu.
- Click . This opens the element setup area.
- Go to the Actions block.
- Click the Add field button. This opens the Select field window.
- Select the checkbox for the field that determines the type of added records.
- Click Select.
- Save the changes.
-
Set up how to handle the action executed on button click.
- Go to the
viewConfigDiff
schema section → page element that adds a record. - Bind the ID of the needed value in the corresponding lookup to the
clicked
button event.
View an example that opens the new page of the "SomeEntity" entity below. Populate the "SomeField" field using the value that has the "SomeValueIDFromTheLookup" ID.
viewConfigDiff schema sectionviewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
/* Button that creates a new record. */
{
"operation": "merge",
"name": "SomeButton",
"values": {
/* Send the base request handler to open the new page of the "SomeEntity" entity. Populate the "SomeField" field using the value that has the "SomeValueIDFromTheLookup" ID. */
"clicked": {
"request": "crt.CreateRecordRequest",
"params": {
"entityName": "SomeEntity",
"defaultValues": [
{
"attributeName": "SomeField",
"value": "SomeValueIDFromTheLookup"
}
]
}
},
...,
}
},
]/**SCHEMA_VIEW_CONFIG_DIFF*/, - Go to the
-
Lock the field on the page for adding records (optional). Lock the field if you need to forbid changing the field value. To do this, select the Read-only checkbox for the page field that includes the record type you can create.
Open a Classic UI page from a custom request handler
Detailed example: Open a Classic UI page from a custom request handler.
To open a Classic UI page from a custom request handler:
-
Add a button to open a Classic UI page if needed. Instructions: Set up Button components (user documentation).
-
Add the dependencies. Instructions: Display the value of a system variable (similarly to step 2). Instead of the
SysValuesService
service, use theHttpClientService
service that sends HTTP requests. -
Set up how to handle the action executed on button click.
- Go to the
viewConfigDiff
schema section → select required element. For example,SomeButton
. - Bind the sending of the custom
usr.SomeCustomRequest
request to the element event.
viewConfigDiff schema sectionviewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
/* Button that opens the page. */
{
"operation": "insert",
"name": "SomeButton",
"values": {
...,
"clicked": {
/* Bind the sending of the custom request to the "clicked" button event. */
"request": "usr.SomeCustomRequest"
}
},
...
},
...
]/**SCHEMA_VIEW_CONFIG_DIFF*/, - Go to the
-
Implement the custom request handler.
-
Go to the
handlers
schema section. -
Implement the
usr.SomeCustomRequest
custom request handler.Open the existing page
- Retrieve the instance of the HTTP client from
@creatio-devkit/common
. - Send the
crt.UpdateRecordRequest
base request handler that opens the page using the specified ID. View the ID of the page in the browser address bar.
View an example of a
usr.SomeCustomRequest
request handler that sends thecrt.UpdateRecordRequest
request handler below. Thecrt.UpdateRecordRequest
request handler opens the page of theSomeEntityCode
entity using theSome-Record-Id
ID.handlers schema sectionhandlers: /**SCHEMA_HANDLERS*/[
{
request: "usr.SomeCustomRequest",
/* 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 handler to open the page of the "SomeEntityCode" entity using the specified ID. */
await handlerChain.process({
type: 'crt.UpdateRecordRequest',
entityName: 'SomeSchemaName',
recordId: 'Some-Record-Id',
$context: request.$context
});
/* Call the next handler if it exists and return its result. */
return next?.handle(request);
}
}
] /**SCHEMA_HANDLERS*/,Create a new page and fill out the fields using the specified values
- Retrieve the instance of the HTTP client from
@creatio-devkit/common
. - Send the
crt.CreateRecordRequest
base request handler that creates a page and populates the fields using the specified values.
View an example of a
usr.SomeCustomRequest
request handler that sends thecrt.CreateRecordRequest
request handler below. Thecrt.CreateRecordRequest
request handler creates the page of theSomeEntityCode
entity and populates the SomeField field using the "Some value" value.handlers schema sectionhandlers: /**SCHEMA_HANDLERS*/[
{
request: "usr.SomeCustomRequest",
/* 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 handler to open the new page of the "SomeEntityCode" entity. Populate the "Some field" field using the "Some value" value. */
await handlerChain.process({
type: 'crt.CreateRecordRequest',
entityName: 'SomeEntityCode',
defaultValues: [{
attributeName: 'SomeField',
value: 'Some value'
}],
$context: request.$context
});
/* Call the next handler if it exists and return its result. */
return next?.handle(request);
}
}
] /**SCHEMA_HANDLERS*/, - Retrieve the instance of the HTTP client from
-
See also
Set up Button components (user documentation)
Display the value of a system variable
Optimize the execution of a custom business logic
Set up typified app pages (user documentation)