Situation:
While working in Netsuite, we always have to write same functions for multiple scripts.
Solution:
We can create a commom script file and use in all required scripts.
Here is how:
1.Utility.js
Create a common script file say Utility.js which will include all your reusable functions.
Then in Nesuite account, create a client script for this script file without deploying it.
2.SampleSuitelet.js
Create a script file(SampleSuitele.js) which will call the functions that are in Utility.js file.
Now create your required script(let’s say a suitelet script) in Nestuite and add its corresponding suitelet script file.
In the Script page, in Libraries sub tab, select that Utility.js file and click add.
Then deploy that suitelet script and execute that script.
Now you can check that your function has been called from suitelet script. |
You can use multiple Utility scripts for single script. Let’s say for the whole netsuite account you have created GlobalUtility.js which includes all general functions, which we generally use for almost all scripts like CheckNull(), SetDefaultValue() etc. And for specific case, where you have some functions, which you are using 5-6 scripts. So for that you have created another utility script let’s say localUtility.js. So you have to select 2 Utility script files in Libraries subtab. you have to select 2 Utility script files in Libraries subtab. |
functions in Netsuite, Libraries in Script page of Netsuite