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?
/**
* @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
}
}
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.
/**
* @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
}
});