Skip to main content
Version: 8.1

Open a page from a custom handler

Level: beginner

Creatio 8 Atlas uses the 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

  1. Add a page button that opens the record page on click at step 1 of the Freedom UI page customization procedure if needed.

  2. Set up how to open the record page from a custom handler at step 2 of the Freedom UI page customization procedure.

    1. Enable the HandlerChainService service that opens pages. Enable the service similarly to the display procedure for the value of system variables.

    2. Bind the clicked property to the corresponding request in the viewConfigDiff schema section. Describe the business logic that opens the page in the handlers schema section. The clicked property is responsible for the action performed on button click.

      View an example that binds the clicked property to the usr.SomeRequest custom request below.

      viewConfigDiff schema section
      viewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
      {
      "values": {
      "clicked": {
      /* Bind a custom usr.SomeRequest request to the clicked button event. */
      "request": "usr.SomeRequest"
      }
      },
      }
      ]/**SCHEMA_VIEW_CONFIG_DIFF*/,
    3. Add the implementation of a custom request to the handlers schema section.

      To open a page:

      1. Get an instance of the HandlerChainService singleton service that opens pages.
      2. Send a crt.UpdateRecordRequest system request that opens the page by the specified ID.

      View an example of the usr.SomeRequest request handler that sends the crt.UpdateRecordRequest system request below. The crt.UpdateRecordRequest request opens the page of the SomeSchemaName record with the SomeRecordId ID.

      handlers schema section
      handlers: /**SCHEMA_HANDLERS*/[
      {
      request: "usr.SomeRequest",
      /* Implementation of the custom request 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 request 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:

      1. Get an instance of the HandlerChainService singleton service that opens pages.
      2. Send the crt.CreateRecordRequest system request that creates a page with fields populated with the specified values.

      View an example of the usr.SomeRequest request handler that sends the crt.CreateRecordRequest system request below. The crt.CreateRecordRequest request opens the SomeSchemaName record page and populates the SomeField field with the "SomeRecordId" value.

      handlers schema section
      handlers: /**SCHEMA_HANDLERS*/[
      {
      request: "usr.SomeRequest",
      /* Implementation of the custom request 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 request 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*/,

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

  1. Take steps 1-2 from the procedure to open the record page from a custom handler.

  2. 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 request to the handlers schema section.

    1. Get an instance of the HandlerChainService singleton service that opens pages.
    2. Send a crt.OpenPageRequest system request that opens the Freedom UI page with the specified name.

    View an example usr.SomeRequest request handler that sends the crt.OpenPageRequest system request below. The crt.OpenPageRequest request opens the SomePageName page.

    handlers schema section
    handlers: /**SCHEMA_HANDLERS*/[
    {
    request: "usr.SomeRequest",
    /* Implementation of the custom request 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 request 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*/,

View a detailed example that opens a Freedom UI page in a separate article: Open a Freedom UI page from a custom handler.


See also

Freedom UI page customization basics

Display the value of a system variable