2
votes

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
  }
}
4
I tried replacing the search reference object with a search creation that worked in a previous script, and replacing the id with an integer.Sarah Lindmar
Very odd; looks correct to me. How are you trying to create the script? Double-check that the file you're selecting has actually been updated with this content.erictgrubaugh
@erictgrubaugh, thanks for the help! I solved it, please see my answer below.Sarah Lindmar
Ah, yes, I see it now; glad you found it.erictgrubaugh

4 Answers

4
votes

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
  }
});
1
votes

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
votes

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.

1
votes

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