Manage the system setting values
@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:
-
If needed, add a label to display the value of a system setting. Instructions: Set up a Label component (user documentation).
-
Add the dependencies. Instructions: Display the value of a system variable (similarly to step 2). Instead of the
SysValuesServiceservice, use theSysSettingsServiceservice that manages system settings. -
Add an attribute. Instructions: Set up the field display condition (step 2).
-
Bind an attribute to the label. Instructions: Set up the field display condition (similarly to step 3). Instead of the
visibleproperty, use thecaptionproperty that handles the text displayed in the element. -
Implement the base request handler.
-
Go to the
handlersschema section. -
Add a custom implementation of the
crt.HandleViewModelResumeRequestbase request handler.- Create an instance of the system setting service from
@creatio-devkit/common. - Retrieve the value of the system setting and specify data in the corresponded attribute.
- Implement the business logic that changes the system setting value.
- Specify data in the corresponding attribute.
- Create an instance of the system setting service from
View an example of a
crt.HandleViewModelResumeRequestrequest handler that changes thesomeSystemSettingsystem setting and specifies the value in theSomeAttributeattribute, below.handlers schema sectionhandlers: /**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)