Reading and Saving System Settings on a Creatio Freedom UI Page

To access System Settings in a Creatio Freedom UI page, there is a simple, built-in module you can use that is available in the new Creatio DevKit SDK that can be used in Freedom UI pages.

To use this devkit, you’ll need to add “@creatio-devkit/common” to the modules list of your page. This will look like this (note the “@creatio-devkit/common” in the square brackets and the sdk without quotes in the parenthesis):

define("UsrMyCustomEntity_FormPage", /**SCHEMA_DEPS*/["@creatio-devkit/common"] /**SCHEMA_DEPS*/, 
function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ {
	return {
		// ... the rest of the page here
	};
});

Now, with that module available, you can access things in the SDK, such as the SysSettingsService. You’ll need to create an instance, and can then use it to read or write to system settings.

const sysSettingsService = new sdk.SysSettingsService();

// read a system setting
const someSetting = await sysSettingsService.getByCode("UsrSomeSetting");

// write to a system setting
await sysSettingsService.update({
	code: "UsrSomeSetting",
	value: "Some new value"
});

The nice thing about this new service is that it returns a promise, rather than using a callback as the older utility module, so you can await it if needed to get the value synchronously, as shown above.

Additionally you can pass an array of system setting codes to getByCodes (plural) to retrieve several system settings all at once:

const multiSettings = await sysSettingsService.getByCodes(["UsrSomeSetting", "UsrAnotherSetting", "UsrSetting3"]);
Want content like this delivered to your inbox? Sign up for our newsletter!
ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *