SuiteScript 2 结果集
SuiteScript 2 result set
我正在用 2.0 编写脚本,这是代码片段。
var resultSet = [];
var result = search.load({
id:'customsearch_autosend_statement_invoice'
}).run().each(function( item ) {
resultSet.push(item);
});
如果我 运行 在普通界面中保存搜索,我会得到很多行,例如 2000 多行,但是如果我 运行 这段代码,我会返回 1 行,即使使用 each 函数和将项目添加到另一个数组我只得到一行。我在文档中没有看到任何关于此的信息。谁能告诉我这是为什么?我很难过。在此先感谢您的帮助
我找到了答案,但不是因为我应该看到它,这些示例没有试图告诉您必须 return 从 each 方法为真才能继续接收行。所以答案是,在 "each" 函数的末尾,您必须 return 一个真值才能接收下一行。像这样,如果我想念你的post,谢谢你的努力。
var resultSet = [];
var result = search.load({
id:'customsearch_autosend_statement_invoice'
}).run().each(function( item ) {
resultSet.push(item);
return true;
});
在文档中有详细说明,回调函数returns一个布尔值,可用于停止或继续迭代:
Use a developer-defined function to invoke on each row in the search
results, up to 4000 results at a time. The callback function must use
the following signature: boolean callback(result.Result result); The
callback function takes a search.Result object as an input parameter
and returns a boolean which can be used to stop the iteration with a
value of false, or continue the iteration with a value of true.
...
mySearch.run().each(function(result) {
var entity = result.getValue({
name: 'entity'
});
var subsidiary = result.getValue({
name: 'subsidiary'
});
return true;
});
...
我正在用 2.0 编写脚本,这是代码片段。
var resultSet = [];
var result = search.load({
id:'customsearch_autosend_statement_invoice'
}).run().each(function( item ) {
resultSet.push(item);
});
如果我 运行 在普通界面中保存搜索,我会得到很多行,例如 2000 多行,但是如果我 运行 这段代码,我会返回 1 行,即使使用 each 函数和将项目添加到另一个数组我只得到一行。我在文档中没有看到任何关于此的信息。谁能告诉我这是为什么?我很难过。在此先感谢您的帮助
我找到了答案,但不是因为我应该看到它,这些示例没有试图告诉您必须 return 从 each 方法为真才能继续接收行。所以答案是,在 "each" 函数的末尾,您必须 return 一个真值才能接收下一行。像这样,如果我想念你的post,谢谢你的努力。
var resultSet = [];
var result = search.load({
id:'customsearch_autosend_statement_invoice'
}).run().each(function( item ) {
resultSet.push(item);
return true;
});
在文档中有详细说明,回调函数returns一个布尔值,可用于停止或继续迭代:
Use a developer-defined function to invoke on each row in the search results, up to 4000 results at a time. The callback function must use the following signature: boolean callback(result.Result result); The callback function takes a search.Result object as an input parameter and returns a boolean which can be used to stop the iteration with a value of false, or continue the iteration with a value of true.
...
mySearch.run().each(function(result) {
var entity = result.getValue({
name: 'entity'
});
var subsidiary = result.getValue({
name: 'subsidiary'
});
return true;
});
...