我正在尝试通过 SuiteScript 检索 Netsuite 中的记录。我想使用 lastmodifieddate
列来获取特定时间戳之后的记录。
我目前正在做的事情:
var filters = [new nlobjSearchFilter('lastmodifieddate', null, 'notbefore', time)];
var columns = [new nlobjSearchColumn('lastmodifieddate')];
var newSearch = nlapiCreateSearch(table, filters, columns);
var searchResultSet = newSearch.runSearch();
var back = nextEndIndex - 1000
var results = searchResultSet.getResults(back, nextEndIndex);
其中 time
是日期时间 JS,nextEndIndex
是结果的索引计数器。
这适用于某些对象,但大多数 Netsuite 对象在记录浏览器中没有 lastmodifieddate
列。是否有 lastmodifieddate
的内置变量?如果有,我如何在nlapiCreateSearch
中使用它?如果您有更好的方法,我将不胜感激。
最佳答案
这是 SuiteScript 2.0 的一个简单示例。
define(['N/search'],function(search){
function test(chkDate){
log.debug(chkDate);
var empSearch=search.create({
type:search.Type.EMPLOYEE,
columns:['internalid','firstname','lastmodifieddate'],
filters:['lastmodifieddate','after',chkDate]
}).run().each(function(result){
log.debug(JSON.stringify(result));
return true;
});
}
test('05/30/2017');
});
此示例正在搜索员工,因为我不确定您正在查看哪种记录类型。以下是可用于构建搜索的信息的链接:
- Records Browser (查看过滤器和列中每个部分的底部):
- Search Operators (显示哪些字段类型使用哪些字段)
- API Docs
关于search - Netsuite Suitescript : How to retrieve records based on last modified date?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44300891/