Skip to main content
Version: 8.1

Hide functionality on a page

Level: beginner

Hide a functionality at the development stage

@creatio-devkit/common includes the FeatureService service to check the feature status.

Detailed example: Hide a functionality at the development stage on a page.

To hide a functionality at the development stage:

  1. If needed, add a component that contains the functionality at the development stage. Instructions: Element setup examples (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 FeatureService service that checks the feature status.

  3. Add an attribute. Instructions: Set up the field display condition (step 2).

  4. Bind an attribute to the component. Instructions: Set up the field display condition (step 3).

  5. Implement the base request handler.

    1. Go to the handlers schema section.

    2. Add a custom implementation of the crt.HandleViewModelInitRequest base request handler.

      1. Create an instance of the service that checks the feature status from @creatio-devkit/common.
      2. Retrieve the status of the feature that has the corresponding code and specify the status in the corresponding attribute.

    View an example of a crt.HandleViewModelInitRequest request handler that retrieves the status of the feature that has the SomeFeatureCode code and specify the status in the SomeAttribute attribute, below.

    handlers schema section
    handlers: /**SCHEMA_HANDLERS*/[
    {
    request: "crt.HandleViewModelInitRequest",
    /* Custom implementation of a system request handler. */
    handler: async (request, next) => {
    /* Create an instance of the service that checks the feature status from "@creatio-devkit/common." */
    const featureService = new sdk.FeatureService();
    /* Retrieve the status of the feature that has the "SomeFeatureCode" code and specify the status in the "IsFeatureDeveloped" attribute. */
    request.$context.IsFeatureDeveloped = await featureService.getFeatureState('SomeFeatureCode');
    /* Call the next handler if it exists and return its result. */
    return next?.handle(request);
    }
    }
    ]/**SCHEMA_HANDLERS*/,

Hide a functionality behind access permissions

@creatio-devkit/common includes the RightsService service to check access permissions.

Detailed example: Hide the functionality on a page behind access permissions.

To hide a functionality behind access permissions:

  1. If needed, add a component that contains the functionality that requires access permissions. Instructions: Element setup examples (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 RightsService service that checks access permissions.

  3. Add an attribute. Instructions: Set up the field display condition (step 2).

  4. Bind an attribute to the component. Instructions: Set up the field display condition (step 3).

  5. Implement the base request handler.

    1. Go to the handlers schema section.

    2. Add a custom implementation of the crt.HandleViewModelInitRequest base request handler.

      1. Create an instance of the service that checks access permissions from @creatio-devkit/common.
      2. Retrieve data about the user's access permission to the corresponding system operation.
      3. Specify the data about the user's access permission in the corresponding attribute.

    View an example of a crt.HandleViewModelInitRequest request handler that retrieves data about the user's access permission to the SomeOperation system operation and specify it in the SomeAttribute attribute, below.

    handlers schema section
    handlers: /**SCHEMA_HANDLERS*/[
    {
    request: "crt.HandleViewModelInitRequest",
    /* Custom implementation of a system request handler. */
    handler: async (request, next) => {
    /* Create an instance of the service that checks access permissions from "@creatio-devkit/common." */
    const rightService = new sdk.RightsService();
    /* Retrieve data about the user's access permission to the "SomeOperation" system operation. */
    const someVariable = await rightService.getCanExecuteOperation('SomeOperation');
    /* Specify data about the user's access permission in the "SomeAttribute" attribute. */
    request.$context.SomeAttribute = someVariable;
    /* Call the next handler if it exists and return its result. */
    return next?.handle(request);
    }
    }
    ]/**SCHEMA_HANDLERS*/,

See also

Element setup examples (user documentation)

Display the value of a system variable

Customize fields (Freedom UI)