This topic contains 3 replies, has 0 voices, and was last updated by ironside 8 years, 1 month ago.

  • Author
    Posts
  • #1793

    darrenhillconsulting

    Ok,

    Hoping this is an easy one (that’s somehow eluded me). I want to create a simply library that holds an enumeration of id’s, so that I can use it across several. Easy Peasy in SS 1.0, but how do I do that in SS 2.0?
    This is a cached copy. Click here to see the original post.

  • #1794

    david.smith

    Just create it as a javascript object in a separate file. In your define just call on the file.

    Code:
    define([‘N/record’, ‘N/search’, ‘N/ui/serverWidget’,’./js/createHtmlTable’, ‘N/file’,’./accounting’],
    /**
    * @param {record} record
    * @param {search} search
    * @param {serverWidget} serverWidget
    */
    function(record, search, serverWidget,table,file,accounting) {

  • #1795

    chanarbon

    Hi Darren,

    I agree with David’s note above. You simply need to create a javascript file that is SuiteScript 2.0 compliant similar to the one below

    Code:
    /**
    *
    * @NModuleScope TargetAccount
    *
    */

    define([“N/record”, “N/email”, “N/search”], function(record, email, search){

    function fxn1(){
    ….
    }

    function fxn2(){
    ….
    }

    return {
    libFxn1 : fxn1,
    libFxn2 : fxn2
    }

    })
    Then calling it would be simply following the details on Module Dependency Path (https://netsuite.custhelp.com/app/an…il/a_id/45053/) or require.config() (https://netsuite.custhelp.com/app/an…il/a_id/50900/)

    Please note that the name of the functions when used on your scripts would be the aliases declared on the return object of your library.

  • #1796

    ironside

    TypeScript:

    file ‘myEnums.ts’ in same file cabinet folder as ‘myScript.ts’

    PHP Code:

    export enum MyEnum { foo,bar,baz } 

    file ‘myScript.ts’

    PHP Code:

    import {MyEnum} from ‘./myEnums’

    var x:MyEnum = MyEnum.foo

You must be logged in to reply to this topic.