Skip to main content
Version: 8.1

Optimize the execution of a custom business logic

Level: intermediate
note

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:

  1. Create an app based on the Records & business processes template if needed. Instructions: Create an app manually (user documentation).

  2. Add one or more components whose business logic execution to optimize if needed. Instructions: Step 2. Set up the app form page (user documentation).

  3. 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*/ {
    ...
    };
    );
  4. Set up how to handle the action executed on button click.

    1. Go to the viewConfigDiff schema section → select required element. For example, SomeButton.
    2. Bind the sending of the custom usr.SomeCustomRequest request to the element event.
    viewConfigDiff schema section
    viewConfigDiff: /**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*/,
  5. Implement the custom request handler.

    For example, implement the custom usr.SomeCustomRequest request handler.

    1. Go to the handlers schema section.
    2. Create an instance of the CrtZoneService service.
    3. 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 section
    handlers: /**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*/,
  6. 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)