This topic contains 4 replies, has 0 voices, and was last updated by jmacdonald 7 years, 11 months ago.

  • Author
    Posts
  • #1423

    jmacdonald

    I 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.

  • #1424

    chanarbon

    Hi 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

  • #1425

    jmacdonald

    Thanks 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() ?

  • #1426

    JacksonP

    You 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 here

    function fieldChanged(scriptContext){
    mylib.someFunction();
    }

  • #1427

    jmacdonald

    JacksonP Thanks for the example, this answers all my questions!

You must be logged in to reply to this topic.