Open a page from a custom handler
Creatio 8 Atlas uses the sdk.HandlerChainService
service to open pages. Creatio 7.X and Creatio 8 Atlas use the same method to open record pages. You can pass the needed default column values when Creatio adds a record.
Creatio 8 Atlas provides the following actions to open pages from a custom handler:
- Open a record page from a custom handler.
- Open a Freedom UI page from a custom handler.
Open a record page from a custom handler
-
Add a page button that opens the record page on click at step 1 of the Freedom UI page customization procedure if needed.
-
Set up how to open the record page from a custom handler at step 2 of the Freedom UI page customization procedure.
-
Enable the
sdk.HandlerChainService
service that opens pages. Enable the service similarly to the display procedure for the value of system variables. -
Bind the
clicked
property to the corresponding query in theviewConfigDiff
schema section. Describe the business logic that opens the page in thehandlers
schema section. Theclicked
property is responsible for the action performed on button click.View an example that binds the
clicked
property to theusr.SomeRequest
custom query below.viewConfigDiff schema sectionviewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
{
"values": {
"clicked": {
/* Bind a custom usr.SomeRequest query to the clicked button event. */
"request": "usr.SomeRequest"
}
},
}
]/**SCHEMA_VIEW_CONFIG_DIFF*/, -
Add the implementation of a custom query to the
handlers
schema section.To open a page:
- Get an instance of the
sdk.HandlerChainService
singleton service that opens pages. - Send a
crt.UpdateRecordRequest
system query that opens the page by the specified ID.
View an example of the
usr.SomeRequest
query handler that sends thecrt.UpdateRecordRequest
system query below. Thecrt.UpdateRecordRequest
query opens the page of theSomeSchemaName
record with theSomeRecordId
ID.handlers schema sectionhandlers: /**SCHEMA_HANDLERS*/[
{
request: "usr.SomeRequest",
/* Implementation of the custom query handler. */
handler: async (request, next) => {
/* Get an instance of the singleton service that opens pages. */
const handlerChain = sdk.HandlerChainService.instance;
/* Send a crt.UpdateRecordRequest system query that opens the page with the specified ID. */
await handlerChain.process({
type: 'crt.UpdateRecordRequest',
entityName: 'SomeSchemaName',
recordId: 'SomeRecordId',
$context: request.$context
});
/* Call the next handler if it exists and return its result. */
return next?.handle(request);
}
}
] /**SCHEMA_HANDLERS*/,To open the page and populate the fields with the specified values:
- Get an instance of the
sdk.HandlerChainService
singleton service that opens pages. - Send the
crt.CreateRecordRequest
system query that creates a page with fields populated with the specified values.
View an example of the
usr.SomeRequest
query handler that sends thecrt.CreateRecordRequest
system query below. Thecrt.CreateRecordRequest
query opens theSomeSchemaName
record page and populates the SomeField field with the "SomeRecordId" value.handlers schema sectionhandlers: /**SCHEMA_HANDLERS*/[
{
request: "usr.SomeRequest",
/* Implementation of the custom query handler. */
handler: async (request, next) => {
/* Get an instance of the singleton service that opens pages. */
const handlerChain = sdk.HandlerChainService.instance;
/* Send a crt.CreateRecordRequest system query that opens the specified page. Populate the [SomeField] field with the SomeFieldValue value. */
await handlerChain.process({
type: 'crt.CreateRecordRequest',
entityName: 'SomeSchemaName',
defaultValues: [{
attributeName: 'SomeField',
value: 'SomeFieldValue'
}],
$context: request.$context
});
/* Call the next handler if it exists and return its result. */
return next?.handle(request);
}
}
] /**SCHEMA_HANDLERS*/, - Get an instance of the
-
View a detailed example that opens a record page in a separate article: Open a record page from a custom handler.
Open a Freedom UI page from a custom handler
-
Take steps 1-2 from the procedure to open the record page from a custom handler.
-
Set up how to open a Freedom UI page from a custom handler at step 2 of the procedure for opening the record page from a custom handler. To do this, add the implementation of a custom query to the
handlers
schema section.- Get an instance of the
sdk.HandlerChainService
singleton service that opens pages. - Send a
crt.OpenPageRequest
system query that opens the Freedom UI page with the specified name.
View an example
usr.SomeRequest
query handler that sends thecrt.OpenPageRequest
system query below. Thecrt.OpenPageRequest
query opens theSomePageName
page.handlers schema sectionhandlers: /**SCHEMA_HANDLERS*/[
{
request: "usr.SomeRequest",
/* Implementation of the custom query handler. */
handler: async (request, next) => {
/* Get an instance of the singleton service that opens pages. */
const handlerChain = sdk.HandlerChainService.instance;
/* Send a crt.OpenPageRequest system query that opens the page. */
await handlerChain.process({
type: 'crt.OpenPageRequest',
schemaName: 'SomePageName',
$context: request.$context
});
/* Call the next handler if it exists and return its result. */
return next?.handle(request);
}
}
] /**SCHEMA_HANDLERS*/, - Get an instance of the
View a detailed example that opens a Freedom UI page in a separate article: Open a Freedom UI page from a custom handler.