Hello Creatio community
I have developed a page using Freedom UI. I want to develop some core functions that i want to call in different Freedom UI screens. For example function calculate as shown below.
define("ApplicationFormSection_FormPage", /**SCHEMA_DEPS*/["@creatio-devkit/common"]/**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ { function calculate(value1, value2) { return value1 + value2; } return { viewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[..]/**SCHEMA_VIEW_CONFIG_DIFF*/, viewModelConfigDiff: /**SCHEMA_VIEW_MODEL_CONFIG_DIFF*/[..]/**SCHEMA_VIEW_MODEL_CONFIG_DIFF*/, modelConfigDiff: /**SCHEMA_MODEL_CONFIG_DIFF*/[..]/**SCHEMA_MODEL_CONFIG_DIFF*/, handlers: /**SCHEMA_HANDLERS*/[ { request: "crt.HandleViewModelAttributeChangeRequest", handler: async (request, next) => { if (request.attributeName === "Field1" && !request.silent) { var sum = calculate(1, 2); } return next?.handle(request); } }, ] }
This approach doesn't work because every time i change the screen the function is removed automatically.
Is there a way I can develop some core functions in a different module and call this module inside my "ApplicationFormSection_FormPage" freedom UI page?
Can you give an example for my case?
Best regards
Like
Hello,
A better approach is to use modules for page code. I try to add as little code to the page request handlers as possible and move all code to modules/classes. See https://customerfx.com/article/organizing-code-for-creatio-freedom-ui-pages-with-modules/
Ryan