Skip to main content
Version: 8.1

Manage the system setting values on a page

Level: beginner

Creatio 8 Atlas uses the sdk.SysSettingsService service to manage system settings.

To manage the value of a system setting:

  1. Add a caption that displays the value of system setting on the page on step 1 of the Freedom UI page customization procedure if needed.

  2. Set up how to manage the value of a system setting on the page on step 2 of the Freedom UI page customization procedure.

    1. Enable the sdk.SysSettingsService system setting service. To do this, add the @creatio-devkit/common dependency to the AMD module.

      View an example that adds a dependency to the UsrAppClientSchemaName AMD module below.

      AMD module dependencies
      /* AMD module declaration. */
      define("UsrAppClientSchemaName", /**SCHEMA_DEPS*/["@creatio-devkit/common"] /**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ {
      return {
      ...
      };
      });
    2. Add an attribute that stores data to the viewModelConfig schema section. Add the attribute similarly to the procedure for setting up the field display condition.

    3. Bind the caption property to the corresponding model attribute in the viewConfigDiff schema section. Bind the property similarly to the setup procedure for the field display condition. Instead of the visible property, use the caption property that displays the text in the element.

    4. Add a custom implementation of the crt.HandlerViewModelInitRequest system query handler to the handlers schema section. The handler is executed when the View model is initialized.

      1. Instantiate the system value service from @creatio-devkit/common.
      2. Load the system setting value and write it to the corresponding attribute.
      3. Implement the business logic that changes the system setting value and update the value of the corresponding attribute.

      View an example of a crt.HandleViewModelInitRequest query handler with someVariable calculation result written to the SomeAttributeName attribute below.

      handlers schema section
      handlers: /**SCHEMA_HANDLERS*/[
      {
      request: "crt.HandleViewModelInitRequest",
      /* Custom implementation of a system query handler. */
      handler: async (request, next) => {
      /* Wait for the rest of the initialization handlers to finish. */
      await next?.handle(request);
      /* Instantiate a system setting service from @creatio-devkit/common. */
      const sysSettingsService = new sdk.SysSettingsService();
      /* Retrieve the value of the SomeSystemSetting system setting and write it to the SomeAttributeName attribute. */
      const someVariable = await sysSettingsService.getByCode('SomeSystemSetting');
      request.$context.SomeAttributeName = someConst.displayValue;
      /* Calculate the value. */
      ...;
      /* Update the result of someVariable calculation to the SomeAttributeName attribute. */
      request.$context.SomeAttributeName = someVariable;
      }
      }
      ]/**SCHEMA_HANDLERS*/,

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


See also

Freedom UI page customization basics

Customize page fields