Skip to main content
Version: 8.1

Display the value of a system variable

Level: beginner

Creatio 8 Atlas uses the sdk.SysValuesService service to manage system variables.

In Creatio 8 Atlas, you can access system variables differently from the previous versions. In this version, write the system variable name in lowercase without _ delimiters and the CURRENT prefix. View the complete list of system variables in a separate article: System variables list in Freedom UI.

To display the value of a system variable on a page:

  1. Add a a caption that displays the values ​​of system variables on the page on step 1 of the Freedom UI page customization procedure if needed.

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

    1. Enable the sdk.SysValuesService system variable 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 viewModelConfigDiff 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. Depending on the value of the attribute (true or false), the handler executes different business logic.

      1. Instantiate the system value service from @creatio-devkit/common.
      2. Load system values.
      3. Calculate the value and write the calculation result to the corresponding attribute if needed.

      View an example of a crt.HandlerViewModelInitRequest 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) => {
      /* Instantiate the system value service from @creatio-devkit/common. */
      const sysValuesService = new sdk.SysValuesService();
      /* Load system values. */
      const sysValues = await sysValuesService.loadSysValues();
      /* Calculate the value. */
      const someVariable = sysValues.systemVariable;
      ...;
      /* Write the result of someVariable calculation to the SomeAttributeName attribute. */
      request.$context.SomeAttributeName = someVariable;
      /* Call the next handler if it exists and return its result. */
      return next?.handle(request);
      }
      }
      ]/**SCHEMA_HANDLERS*/,

Detailed example: Display the values of system variables on a page.


See also

Freedom UI page customization basics

Customize page fields