Optimize the execution of a custom business logic
Creatio lets you execute high-load requests in the background and navigate between pages regardless of whether the request is complete or still in progress. Examples of high-load requests are sending data to Google Analytics, background data processing with further sending to the server, etc.
Creatio zone lets you optimize the execution of custom business logic. The CrtZoneService
service and runOutside()
service method implements the functionality of Creatio zone. The runOutside()
method is similar to the runOutsideAngular()
Angular method. Learn more: vendor documentation (official Angular documentation).
General procedure to optimize the execution of a custom business logic using Creatio zone:
-
Create an app based on the Records & business processes template if needed. Instructions: Create an app manually (user documentation).
-
Add one or more components whose business logic execution to optimize if needed. Instructions: Step 2. Set up the app form page (user documentation).
-
Enable the
CrtZoneService
service that optimizes the execution of custom business logic using Creatio zone. To do this, add@creatio-devkit/common
to the AMD module as a dependency.View an example that adds a dependency to the
UsrAppClientSchemaName
AMD module below.AMD module dependencies/* Declare the AMD module. */
define("UsrAppClientSchemaName", /**SCHEMA_DEPS*/["@creatio-devkit/common"] /**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ {
...
};
); -
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 calls the {JSON} Placeholder external web service from the request 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.
For example, implement the custom
usr.SomeCustomRequest
request handler.- Go to the
handlers
schema section. - Create an instance of the
CrtZoneService
service. - Implement the business logic to switch between pages regardless of whether the request to the external web service is complete or still in progress. To do this, use the
runOutside()
method.
handlers schema sectionhandlers: /**SCHEMA_HANDLERS*/[
{
request: "usr.SomeCustomRequest",
/* Implement the custom request handler. */
handler: async (request, next) => {
/* Create an instance of the CrtZoneService service. */
const zoneService = new sdk.CrtZoneService();
...;
/* Implement the business logic to switch between pages regardless of whether the request to the external web service is complete or still in progress. */
zoneService.runOutside(async () => {
/* Custom business logic. */
...;
});
}
}
]/**SCHEMA_HANDLERS*/, - Go to the
-
Save the changes.
As a result, Creatio will navigate between pages regardless of whether the request to the external web service is complete or still in progress.
See also
Manage apps (user documentation)
Set up the app UI (user documentation)
Resources
runOutsideAngular()
method (official Angular documentation)