This topic contains 4 replies, has 0 voices, and was last updated by jmacdonald 7 years, 11 months ago.
-
AuthorPosts
-
December 2, 2016 at 2:59 am #1423
jmacdonaldI have been trying to add a library file to a 2.0 script although I seem to be having trouble. Before when I added a library script to a 1.0 script I simply added it to the “Libraries” tab when creating the script record. However when I try this on a 2.0 script no libraries tab appears and only a “Buttons” tab is shown. I am still relatively new to netsuite so if I have missed anything out please let me know, thanks in advance for any light that can be shed on this issue.
This is a cached copy. Click here to see the original post. -
December 2, 2016 at 6:38 am #1424
chanarbonHi jmacdonald ,
For SuiteScript 2.0, you should have the libraries listed on the dependencies on the script itself. This means that the libraries are linked programmatically as modules
-
December 2, 2016 at 7:06 am #1425
jmacdonaldThanks for the response chanarbon ,
By adding to the dependencies do you mean adding a reference to my library file in the define statement, such as define([‘./mylibraryscript.js’], ?
and if so do I then have to use mylibraryscript.someMethod() to run methods or could I simply use someMethod() ?
-
December 2, 2016 at 7:35 am #1426
JacksonPYou can set it to whatever variable you want when you pass it in to the function
Code:
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
* @NModuleScope Public
*/
define([‘N/currentRecord’, ‘./mylibraryscript.js’],
/**
* @param {currentRecord} currentRecord
*/
function(currentRecord, mylib) { // set the variable herefunction fieldChanged(scriptContext){
mylib.someFunction();
} -
December 2, 2016 at 7:48 am #1427
jmacdonaldJacksonP Thanks for the example, this answers all my questions!
-
AuthorPosts
You must be logged in to reply to this topic.
