2

I am trying to upload a Map/reduce type script to netsuite following a suitescript 2.0 training guide. I am receiving the following error: "SuiteScript 2.0 entry point scripts must implement one script type function."

I'm using the getInputData() and map() functions. Returning a reference object pointing to a saved search. Then extracting and logging the context value and the parsed context value (comparing json strings and js objects in the lesson).

Anyone see a syntax error, know what I might be missing, or what I can test for?

Code:

/**
* @NApiVersion 2.x
* @NScriptType MapReduceScript
*/

define(['N/search']),
function(search) {
  function getInputData() {
    return { type: 'search', id: 'customsearch_iii_payments' };
  }
  function map(context) {
    var jsonResult = context.value
    var searchResult = JSON.parse(context.value);
    log.debug('JSON result' + jsonResult);
    log.debug('Search Result' + searchResult);
  }

  return {
    getInputData: getInputData,
    map: map
  }
}
Community
  • 1
  • 1
Sarah Lindmar
  • 99
  • 1
  • 10

4 Answers4

4

It was a netsuite specific syntax error my linter didn't catch. My script definition wasn't wrapping the entire script, just the module declarations.

Working Code:

/**
 * @NApiVersion 2.x
 * @NScriptType MapReduceScript
 * @NModuleScope SameAccount
 */

define(['N/search'],
function(search) {
  function getInputData() {
    return { type: 'search', id: 'customsearch_iii_payments' };
  }
  function map(context) {
    var jsonResult = context.value
    var searchResult = JSON.parse(context.value);
    log.debug('JSON result' + jsonResult);
    log.debug('Search Result' + searchResult);
  }

  return {
    getInputData: getInputData,
    map: map
  }
});
Community
  • 1
  • 1
Sarah Lindmar
  • 99
  • 1
  • 10
2

Also check the @NScriptType notation, in case you have ScheduleScript, netsuite will expect you to have a function called ¨execute¨ on the return object no matter if the syntax is correct.

1

I found the issue for me was that my script referenced local files which I hadn't yet uploaded.

Upload other local files before creating a script record.

rsacc
  • 723
  • 1
  • 8
  • 11
1

double check for the require vs define keyword in the main method definition. 2.X ScheduledScript use define

Luke
  • 776
  • 9
  • 24