Hello everyone!
I am working to optimize the performance of User Event Scripts applied to transactions, written in SuiteScript 2.1. During my debugging, I discovered that significant delays occur when my script loads certain Custom Modules, which are also written in SuiteScript 2.1 and function as libraries. To enhance performance, I want to load these Custom Modules only when they are essential.
Here's how I tried to conditionally load the modules based on examples from other forums:
if (formScriptId === 'custform_test') {
require(['../../path_to_lib/lib'], (lib) => {
lib.beforeSubmit(context, formScriptId);
});
}
Alternatively:
if (formScriptId === 'custform_test') {
const lib = require('../../path_to_lib/lib');
lib.beforeSubmit(context, formScriptId);
}
However, I am encountering this error:
{
type: "error.SuiteScriptModuleLoaderError",
name: "INCORRECT_SUITESCRIPT_CONFIGURATION",
message: "Incorrect SuiteScript configuration for module: ../../path_to_lib/lib.js",
stack: [
"at Object.beforeLoad (...)"
]
}
Has anyone encountered this or knows the correct approach to loading modules in this manner? Any assistance would be appreciated!