Matt Kraemer
Matt Kraemer

Reputation: 53

Accessing NetSuite modules from Config file scripts (SuiteScript)

I am trying to build a JS file to place in the file cabinet to reference my most used functions I constantly rebuild. I have been able to access it by placing the script in the file cabinet and using the @NAmdConfig to reference the functions. However, I cannot access the NetSuite modules in these scripts. I cut most of the function off in my example, but if I can return that to my original Map/Reduce script that will suffice. How can I have a third party script of my most used functions while still having access to the NetSuite modules?

/**
 * @NApiVersion 2.1
 * @NModuleScope public
 */

        var MattsFunctions = {
            dynamicTransactionSearch:
                function (sentId) {
                    var thisRecord = record.load({
                        type: record.Type.SALES_ORDER,
                        id: sentId
                    })
                    return thisRecord.id

            }
        }

I have also tried

/**
 * @NApiVersion 2.1
 * @NModuleScope public
 */


define(['N/search', 'N/record'],

    (search, record) => {

        var exports = {};
        var MattsFunctions = {
            dynamicTransactionSearch:
                function (sentId) {
                    var thisRecord = record.load({
                        type: record.Type.SALES_ORDER,
                        id: sentId
                    })
                    return thisRecord.id

                }

        }
        exports.MattsFunctions = MattsFunctions
        return exports

    })

Upvotes: 1

Views: 515

Answers (1)

Matt Kraemer
Matt Kraemer

Reputation: 53

Figured it out. Simply pass the module over in the function you're calling, of course!

Upvotes: 1

Related Questions