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 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:
-
If needed, add a button to open a Classic UI page. 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. Instructions: Optimize the execution of a custom business logic (step 4).
-
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. 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. Thecrt.CreateRecordRequest
request handler creates the page of theSomeEntityCode
entity and populates the SomeField field using the “Some value” value, below.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
-
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:
-
If needed, add a button to open a Freedom UI page. 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. Instructions: Optimize the execution of a custom business logic (step 4).
-
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. Thecrt.OpenPageRequest
request handler opens the Some page page of theSomePageSchema
schema, below.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
-
See also
Set up Button components (user documentation)
Display the value of a system variable