限制在NetSuite中返回的发票对象的数量
本文关键字:对象 返回 NetSuite | 更新日期: 2023-09-27 17:53:07
我正在与客户的NetSuite帐户集成,其中包括提取发票数据,以便创建"首次销售日期"(创建的第一张发票)和"最后销售日期"(创建的最新发票)。我的问题涉及限制响应中返回的发票数量,因为他们的系统中目前有大约265,000个发票记录-其中数百个可能属于一个客户记录。是否有办法为每个客户只请求两个必要的发票记录?
下面是我当前的c#代码:
int invoiceCount = 0;
private void searchInvoices()
{
// This operation requires a valid session
this.login(true);
TransactionSearch transactionsSearch = new TransactionSearch();
TransactionSearchBasic transactionSearchBasic = new TransactionSearchBasic();
transactionSearchBasic.type = new SearchEnumMultiSelectField();
transactionSearchBasic.type.@operator = SearchEnumMultiSelectFieldOperator.anyOf;
transactionSearchBasic.type.operatorSpecified = true;
transactionSearchBasic.type.searchValue = new string[] { "_invoice" };
transactionsSearch.basic = transactionSearchBasic;
SearchResult transactionResponse = _service.search(transactionsSearch);
Invoice[] invoices = new Invoice[transactionResponse.totalRecords];
if (transactionResponse.status.isSuccess)
{
if (transactionResponse.totalRecords > 0)
{
for (int i = 1; i <= transactionResponse.totalPages; i++)
{
invoices = processTransactionSearchResponse(transactionResponse, invoices);
if (transactionResponse.pageIndex < transactionResponse.totalPages)
{
this.setPreferences();
this.login(true);
transactionResponse = _service.searchMoreWithId(transactionResponse.searchId, i + 1);
}
}
}
else
{
_out.info("'nNothing found.");
}
}
}
private Invoice[] processTransactionSearchResponse(SearchResult transResult, Invoice[] invoices)
{
Record[] transactionRecords = transResult.recordList;
Invoice invoice = new Invoice();
foreach (Record rec in transactionRecords)
{
invoice = (Invoice)rec;
invoices[invoiceCount] = invoice;
invoiceCount++;
}
return invoices;
}
totalRecords的长度是265k吗?
如果是这样的话,你就不能说return me X records,但是你可以做一些类似filter by date的事情。
首先创建一个包含所有客户端的搜索,然后创建一个foreach以获取发票或像这样使用交易:
SearchDateField date = new SearchDateField();
date.@operator = SearchDateFieldOperator.before;
date.operatorSpecified = true;
date.searchValue = DateTime.Now.AddDays