Javascript Netsuite 中的报告未显示每一行
Javascript report in Netsuite not showing every line
在 netsuite 的网站构建器 denali 的 ssp 页面中,我有 javascript 我构建的搜索以从发票文档和项目文档中提取信息 2 行。搜索工作正常,但正在被扁平化(即它只为每个内部 ID 返回一行结果,尽管某些自定义字段有多个值),目前没有过滤器、主线或其他应用,尽管我已经尝试将 mainline 设置为 false,但没有任何区别。
相关的代码行是:
var searchResults = nlapiSearchRecord('invoice', null, filters, columns);
return _.map(searchResults, function(result) {
return {
internalid: result.getValue('internalid'),
date: result.getValue('trandate'),
DocNum: result.getValue('tranid'),
TotalAmount: result.getValue('total'),
status: result.getValue('entitystatus'),
PONum: result.getValue('otherrefnum'),
WellNum: result.getValue('custbody9'),
WellName: result.getValue('custbody8'),
fivecode: result.getValue('custitem35','item'),
desc: result.getValue('itemid','item'),
Reason: result.getValue('custbody67'),
Tech: result.getValue('custbody38')
};
});
如何让每一行返回显示?
很可能是 NetSuite 跳过了行项目,因为结果超过 1000 个。
您可以通过添加搜索列
按 internalid
对结果进行排序
columns.push[new nlobjSearchColumn('internalid').setSort()]
这会为您显示 internalid
的多个结果,但仍有一些发票可能不会出现在搜索结果中。
否则,您可以使用以下代码搜索并获取所有结果
var search = nlapiCreateSearch('invoice', filters, columns).runSearch();
var res = [],
currentRes;
var i = 0;
while(i % 1000 === 0){
currentRes = (search.getResults(i, i+1000) || []);
res = res.concat(currentRes);
i = i + currentRes.length;
}
最后,您可以使用您的代码来展平
return _.map(res, function(result) {
return {
internalid: result.getValue('internalid'),
date: result.getValue('trandate'),
DocNum: result.getValue('tranid'),
TotalAmount: result.getValue('total'),
status: result.getValue('entitystatus'),
PONum: result.getValue('otherrefnum'),
WellNum: result.getValue('custbody9'),
WellName: result.getValue('custbody8'),
fivecode: result.getValue('custitem35','item'),
desc: result.getValue('itemid','item'),
Reason: result.getValue('custbody67'),
Tech: result.getValue('custbody38')
};
});
在 netsuite 的网站构建器 denali 的 ssp 页面中,我有 javascript 我构建的搜索以从发票文档和项目文档中提取信息 2 行。搜索工作正常,但正在被扁平化(即它只为每个内部 ID 返回一行结果,尽管某些自定义字段有多个值),目前没有过滤器、主线或其他应用,尽管我已经尝试将 mainline 设置为 false,但没有任何区别。 相关的代码行是:
var searchResults = nlapiSearchRecord('invoice', null, filters, columns);
return _.map(searchResults, function(result) {
return {
internalid: result.getValue('internalid'),
date: result.getValue('trandate'),
DocNum: result.getValue('tranid'),
TotalAmount: result.getValue('total'),
status: result.getValue('entitystatus'),
PONum: result.getValue('otherrefnum'),
WellNum: result.getValue('custbody9'),
WellName: result.getValue('custbody8'),
fivecode: result.getValue('custitem35','item'),
desc: result.getValue('itemid','item'),
Reason: result.getValue('custbody67'),
Tech: result.getValue('custbody38')
};
});
如何让每一行返回显示?
很可能是 NetSuite 跳过了行项目,因为结果超过 1000 个。
您可以通过添加搜索列
按internalid
对结果进行排序
columns.push[new nlobjSearchColumn('internalid').setSort()]
这会为您显示 internalid
的多个结果,但仍有一些发票可能不会出现在搜索结果中。
否则,您可以使用以下代码搜索并获取所有结果
var search = nlapiCreateSearch('invoice', filters, columns).runSearch();
var res = [],
currentRes;
var i = 0;
while(i % 1000 === 0){
currentRes = (search.getResults(i, i+1000) || []);
res = res.concat(currentRes);
i = i + currentRes.length;
}
最后,您可以使用您的代码来展平
return _.map(res, function(result) {
return {
internalid: result.getValue('internalid'),
date: result.getValue('trandate'),
DocNum: result.getValue('tranid'),
TotalAmount: result.getValue('total'),
status: result.getValue('entitystatus'),
PONum: result.getValue('otherrefnum'),
WellNum: result.getValue('custbody9'),
WellName: result.getValue('custbody8'),
fivecode: result.getValue('custitem35','item'),
desc: result.getValue('itemid','item'),
Reason: result.getValue('custbody67'),
Tech: result.getValue('custbody38')
};
});