Discussions
Read on for the latest updates including:
• Agenda Builder launch
• SuiteWorld On Air registration
• New NetSuite Prompt Studio Contest
• And more!
Check out this thread to learn more!
Error When Conditionally Loading Custom Modules in SuiteScript
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); }