是否可以在Map / Reduce脚本中添加库文件

时间:2019-11-01 10:36:41

标签: netsuite suitescript suitescript2.0

我在Suitescripts文件夹中有一个库文件。我想在我的Map / Reduce脚本中包含同样的内容。

我尝试通过在脚本定义中添加文件,但是出现未定义的错误。

define(['N/search', 'N/record', '/SuiteScripts/Date_Sent_From_SF_On_PO'], 
  function(search, record, dateSent) {
    function getInputData() {  
    ...
    }

    function map(context) {
    ...
    var today_date = new Date();
    var newDate = dateSent.Set_Date_Sent_From_SF_On_PO(today_date);
    ...
    }
  })

执行脚本时,其在函数Set_Date_Sent_From_SF_On_PO名称上引发未定义的错误。谁能帮我解决这个问题?谢谢

1 个答案:

答案 0 :(得分:0)

除非您的库文件是用define函数构造的,否则应省略dateSent参数/参数。您仍然可以使用

define(['N/search', 'N/record', '/SuiteScripts/Date_Sent_From_SF_On_PO'], 
  function(search, record) {
    function getInputData() {  
    ...
    }

    function map(context) {
    ...
    var today_date = new Date();
    var newDate = Set_Date_Sent_From_SF_On_PO(today_date);
    ...
    }
  })