首页 > 解决方案 > 从配置文件脚本 (SuiteScript) 访问 NetSuite 模块

问题描述

我正在尝试构建一个 JS 文件以放置在文件柜中,以引用我经常重建的最常用的功能。我已经能够通过将脚本放在文件柜中并使用@NAmdConfig 来引用这些函数来访问它。但是,我无法访问这些脚本中的 NetSuite 模块。我在示例中切断了大部分功能,但如果我可以将其返回到我的原始 Map/Reduce 脚本就足够了。如何在仍然可以访问 NetSuite 模块的同时拥有我最常用功能的第三方脚本?

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

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

            }
        }

我也试过

/**
 * @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

    })

标签: javascriptcallbacknetsuitesuitescriptsuitescript2.0

解决方案


弄清楚了。当然,只需在您正在调用的函数中传递模块!


推荐阅读