A custom module allows you to organize reusable code by creating multiple functions inside it, and you can use these functions anywhere in your code once you include the module in your script file.
Steps to Create and include the custom module in your script:
- Create the Custom Module Script and add the standard modules needed to create a function.
- Add the Multiple functions and return the function names in the custom module file and then upload into your NetSuite Account.
- In your Script file add the custom module you created by adding the file path.
- There are two ways to add the custom module in your script.
1. Use the path directly in your script.
example,
define([“SuitteScripts/Jobin and Jismi IT Services/CustomModule.js”]
(customModule) => {
- You can use at any part of your file
customModule.functionName(paramaterValues)
2. You can add Multiple custom module paths in the JSON file, upload the JSON file and add the JSON file name in your script
example,
In JSON file,
{
“paths” : {
“libraryOne”: “SuitteScripts/Jobin and Jismi IT Services/CustomModule.js”,
“libraryTwo”: “SuitteScripts/Jobin and Jismi IT Services/CustomModule2.js” //you can add multiple custom modules here.
}
}
In your script file,
@NAmdConfig ./jsonFilename.json
define([“libraryOne”, “libraryTwo”],
(libraryOne, libraryTwo) => {
- You can use at any part of your file
customModule.functionName(paramaterValues)