Optimize the execution of a custom business logic
This functionality is available for Creatio 8.1.1 and later.
Creatio version 8.1 and earlier blocks switching between pages while a high-load request to the external web service is still in progress. Examples of high-load requests are sending data to Google Analytics, background data processing with further sending to the server, etc. To navigate between pages, you need to wait until the request is complete.
Since version 8.1.1, Creatio lets you execute requests in the background and navigate between pages regardless of whether the request is complete or still in progress. 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)