Skip to main content
Version: 8.0

Display the value of a system variable

Level: beginner

@creatio-devkit/common includes the sdk.SysValuesService service to manage system variables.

You can access system variables differently from the previous versions. To do this, write the system variable name in lowercase without _ delimiters and the CURRENT prefix. Learn more: System variables list in Freedom UI.

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

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

  1. If needed, add a label to display the value of a system variable. Instructions: Set up a Label component (user documentation).

  2. Add the dependencies. To do this, add @creatio-devkit/common library as a dependency. The library includes the sdk.SysValuesService service to manage system variables.

    View an example that adds the @creatio-devkit/common library as a dependency to the SomeApp_FormPage Freedom UI page schema below.

    AMD module dependencies
    /* Declare the AMD module. */
    define("SomeApp_FormPage", /**SCHEMA_DEPS*/["@creatio-devkit/common"] /**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ {
    return {
    ...
    }
    });
  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.HandlerViewModelInitRequest base request handler.

      1. Create an instance of the system value service from @creatio-devkit/common.
      2. Upload the system variable values.
      3. If needed, handle the system variable value.
      4. Specify data in the corresponding attribute.

    View an example of a crt.HandleViewModelInitRequest request handler that handles the someVariable system variable and specifies the value 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 system value service from "@creatio-devkit/common." */
    const sysValuesService = new sdk.SysValuesService();
    /* Upload the system variable values. */
    const sysValues = await sysValuesService.loadSysValues();
    /* handle the system variable value. */
    const someVariable = sysValues.systemVariable;
    ...;
    /* Specify the "someVariable" value of the system variable 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

Freedom UI page customization basics

Customize fields (Freedom UI)