Skip to main content
Version: 8.1

Open a page from a custom request handler

Level: beginner

@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:

  1. If needed, add a button to open a Classic UI page. Instructions: Set up Button components (user documentation).

  2. Add the dependencies. Instructions: Display the value of a system variable (similarly to step 2). Instead of the SysValuesService service, use the HttpClientService service that sends HTTP requests.

  3. Set up how to handle the action executed on button click. Instructions: Optimize the execution of a custom business logic (step 4).

  4. Implement the custom request handler.

    1. Go to the handlers schema section.

    2. Implement the usr.SomeCustomRequest custom request handler.

      Open the existing page
      1. Retrieve the instance of the HTTP client from @creatio-devkit/common.
      2. 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 the crt.UpdateRecordRequest request handler. The crt.UpdateRecordRequest request handler opens the page of the SomeEntityCode entity using the Some-Record-Id ID.

      handlers schema section
      handlers: /**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
      1. Retrieve the instance of the HTTP client from @creatio-devkit/common.
      2. 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 the crt.CreateRecordRequest request handler. The crt.CreateRecordRequest request handler creates the page of the SomeEntityCode entity and populates the SomeField field using the “Some value” value, below.

      handlers schema section
      handlers: /**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*/,

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:

  1. If needed, add a button to open a Freedom UI page. Instructions: Set up Button components (user documentation).

  2. Add the dependencies. Instructions: Display the value of a system variable (similarly to step 2). Instead of the SysValuesService service, use the HttpClientService service that sends HTTP requests.

  3. Set up how to handle the action executed on button click. Instructions: Optimize the execution of a custom business logic (step 4).

  4. Implement the custom request handler.

    1. Go to the handlers schema section.

    2. Implement the usr.SomeCustomRequest custom request handler.

      1. Retrieve the instance of the HTTP client from @creatio-devkit/common.
      2. Send the crt.OpenPageRequest base request handler that opens the page.

      View an example of a usr.SomeCustomRequest request handler that sends the crt.OpenPageRequest request handler. The crt.OpenPageRequest request handler opens the Some page page of the SomePageSchema schema, below.

      handlers schema section
      handlers: /**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*/,

See also

Set up Button components (user documentation)

Display the value of a system variable

Optimize the execution of a custom business logic

Freedom UI page customization basics