Calling Files in Other Modules for Improved NetSuite Development
Discover how to efficiently call files across modules in NetSuite to streamline your development process and enhance coding efficiency.
Calling Files in Other Modules
Calling Files in Other Modules
If you created the files and folders described in Folder Structure, you can walk through this example to see how to call files in other modules.
Reset the manifest.json file so that all three applications use the same entry point as shown in the following code sample:
1"javascript": {2 "entry_points": {3 "shopping": "Modules/ModuleOne/JavaScript/ModuleOne.js",4 "myaccount": "Modules/ModuleOne/JavaScript/ModuleOne.js",5 "checkout": "Modules/ModuleOne/JavaScript/ModuleOne.js"6 },If you modify ModuleOne.js to add ModuleTwo as a dependency, you can then call it from within ModuleOne.js. For example, you can call ModuleTwo's mountToApp() method as shown in the following code sample:
1define('ModuleOne'2, [3 'ModuleTwo'4 ]5, function6 (7 ModuleTwo8 )9{10 'use strict';11 12 return {13 mountToApp: function ()14 {15 console.log('ModuleOne loaded!');16 ModuleTwo.mountToApp();17 }18 }19})If you save these changes and then restart your local server to test these modifications, the following message displays in your browser's developer console:
ModuleOne loaded!ModuleTwo loaded!This output verifies that calling the file in the second module is working as expected.
Calling files in other modules is not limited to entry point files. This approach works for other types of files in your extension, too. You can reference any file, like views or models, if the file has been properly defined and made available to the application. So, instead of having an entry point file in your second module, you could have a view, model, or any other type of supported file instead. As shown in the preceding code sample, you can simply add it as a dependency and call one of its methods.
Frequently Asked Questions (4)
Can I use this method to call files other than JavaScript entry points in different modules?
What steps need to be taken to call a method from a second module within the first module?
Is it necessary to restart the server after modifying module files and dependencies?
What should I check if the console doesn't display module loading messages as expected?
Was this article helpful?
More in General
- NetSuite 2026.1: Enhancements to Consolidated Reports and SuiteQL
NetSuite 2026.1 introduces new consolidated reports and SuiteQL tool for improved reporting and data integrity.
- Release Notes PDF Availability and Translations in NetSuite
NetSuite provides PDF files for each Release Note update, improving accessibility and user experience.
- Enhanced Commitment Credits for Flexible Billing in NetSuite
Commitment Credits in NetSuite SuiteBilling offer enhanced flexibility for usage-based billing across diverse services.
- New Parent Role Field for Custom Roles in NetSuite 2025.2
The new Parent Role field facilitates easier role management and visibility in NetSuite 2025.2 for administrators.
Advertising
Reach General Professionals
Put your product in front of NetSuite experts who work with General every day.
Sponsor This Category