Ba.Lal
Ba.Lal

Reputation: 310

Is it possible to add a library file in Map/Reduce script

I have a library file in Suitescripts folder. I want to include the same in my Map/Reduce script.

I tried by adding the file in script definition, but getting undefined error.

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);
    ...
    }
  })

When executing the script, its throwing undefined error on the function Set_Date_Sent_From_SF_On_PO name. Can anyone help me to fix this? Thanks

Upvotes: 0

Views: 309

Answers (1)

Nathan Sutherland
Nathan Sutherland

Reputation: 1270

Unless your library file is structured with a define function, you should omit the dateSent argument/parameter. You should still be able to use

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);
    ...
    }
  })

Upvotes: 0

Related Questions