Skip to main content
Version: 8.2

Manage the system setting values

Level: beginner

@creatio-devkit/common includes the SysSettingsService service to manage system settings.

Detailed example: Manage the system setting values on a page.

To manage the value of a system setting:

  1. If needed, add a label to display the value of a system setting. Instructions: Set up a Label component (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 SysSettingsService service that manages system settings.

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

  4. Bind an attribute to the label. Instructions: Set up the field display condition (similarly to step 3). Instead of the visible property, use the caption property that handles the text displayed in the element.

  5. Implement the base request handler.

    1. Go to the handlers schema section.

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

      1. Create an instance of the system setting service from @creatio-devkit/common.
      2. Retrieve the value of the system setting and specify data in the corresponded attribute.
      3. Implement the business logic that changes the system setting value.
      4. Specify data in the corresponding attribute.

    View an example of a crt.HandleViewModelResumeRequest request handler that changes the someSystemSetting system setting and specifies the value in the SomeAttribute attribute, below.

    handlers schema section
    handlers: /**SCHEMA_HANDLERS*/[
    {
    request: "crt.HandleViewModelResumeRequest",
    /* The custom implementation of the system request handler. */
    handler: async (request, next) => {
    /* Wait for the rest of the initialization handlers to finish. */
    await next?.handle(request);
    /* Create an instance of the system setting service from "@creatio-devkit/common." */
    const sysSettingsService = new sdk.SysSettingsService();
    /* Retrieve the value of the "SomeSystemSetting" system setting. */
    const someVariable = await sysSettingsService.getByCode('SomeSystemSetting');
    /* Specify the value of the system setting in the "SomeAttribute" attribute. */
    request.$context.SomeAttribute = someConst.displayValue;
    /* Implement the business logic that changes the system setting value. */
    ...;
    /* Specify the new value of the system setting in the "SomeAttribute" attribute. */
    request.$context.SomeAttribute = someVariable;
    }
    }
    ]/**SCHEMA_HANDLERS*/,

See also

Set up a Label component (user documentation)

Display the value of a system variable

Customize fields (Freedom UI)