Suitescript 2.0 通过列索引获取保存的搜索值

Suitescript 2.0 get saved search value by column index

我正在使用 suitescript 2.0。我尝试使用以下代码获取该报告的价值。我从 suitescript 2.0 documentation

中引用的
/**
 * @NApiVersion 2.x
 * @NScriptType restlet
 */

define(["N/record", "N/error", "N/search", "N/log", "N/format"], function(
  record,
  error,
  search,
  log,
  format
) {
  return {
    get: getProductionIncome
  };

function getProductionIncome(){


 var mySearch = search.load({
 id: 'customsearch_db_tot_rev'
 });
 var resultSet = mySearch.run();
 var firstResult = resultSet.getRange({
 start: 0,
 end: 10
 })[0];
 // get the value of the second column (zero-based index)
 var value = firstResult.getValue(resultSet.columns[1]); 


return "Amount: " + value;
}
});

我收到以下错误。

error code: SSS_MISSING_REQD_ARGUMENT error message: {"type":"error.SuiteScriptError","name":"SSS_MISSING_REQD_ARGUMENT","message":"Result.getValue: Missing a required argument: name","stack":["createError(N/error)","getProductionIncome(/SuiteScripts/revenue_sync_script.js:34)","createError(N/error)"],"cause":{"name":"SSS_MISSING_REQD_ARGUMENT","message":"Result.getValue: Missing a required argument: name"},"id":"","notifyOff":false,"userFacing":true}

我也试过

var AccType= firstResult.getValue({ name: "type" });

但是因为不知道确切的名字所以没能得到结果

error code: SSS_MISSING_REQD_ARGUMENT error message: {"type":"error.SuiteScriptError","name":"SSS_MISSING_REQD_ARGUMENT","message":"Result.getValue: Missing a required argument: name","stack":["createError(N/error)","getProductionIncome(/SuiteScripts/revenue_sync_script.js:34)","createError(N/error)"],"cause":{"name":"SSS_MISSING_REQD_ARGUMENT","message":"Result.getValue: Missing a required argument: name"},"id":"","notifyOff":false,"userFacing":true}

从错误消息来看,您的搜索似乎不包含要获取第二列的 2 列。

请先验证您的搜索是否包含 2 列。

but couldn't get the result because I don't know the exact name.

要获取列名,可以使用column.namecolumn.join 获取连接。 如需进一步阅读,请查看 this