简体   繁体   中英

Can't upload file to SuiteScript

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
  }
}

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

还要检查@NScriptType 符号,如果您有ScheduleScript,无论语法是否正确,netsuite 都希望您在返回对象上有一个名为“execute”的函数。

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM