Skip to main content
Version: 8.1

Open a page from a custom handler

Level: beginner

Creatio 8 Atlas uses the sdk.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 sdk.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 query 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 query below.

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

      To open a page:

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

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

      handlers schema section
      handlers: /**SCHEMA_HANDLERS*/[
      {
      request: "usr.SomeRequest",
      /* Implementation of the custom query 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 query 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 sdk.HandlerChainService singleton service that opens pages.
      2. Send the crt.CreateRecordRequest system query that creates a page with fields populated with the specified values.

      View an example of the usr.SomeRequest query handler that sends the crt.CreateRecordRequest system query below. The crt.CreateRecordRequest query 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 query 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 query 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 query to the handlers schema section.

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

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

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