How to read more than 1000 records return from netsuite search results in c#?

与世无争的帅哥 提交于 2019-12-02 12:23:01

问题


I am not able read all records. It reading only 1st pageindex records. I want read all reacords of all pages. Totalrecords are 2055 but 1st 1000 records only reading. Kinldy someone helpme out in this issues as soon as possible.

TransactionSearchAdvanced ticketSearch = new TransactionSearchAdvanced();
ticketSearch.savedSearchId = "287";
SearchResult results = new SearchResult();
results = _service.search(ticketSearch);

// If everything was okay, start processing records
if (results.status.isSuccess)
    {
        foreach (SearchResult sr in searchMoreResults)
          {
            //System.Console.WriteLine("Results found.");
            foreach (SearchRow searchRow in results.searchRowList)
              {
                TransactionSearchRow SaleTicket = (TransactionSearchRow)searchRow;
                if (SaleTicket.basic != null)
                   {
                     if (SaleTicket.basic.tranId != null)
                      {

                        SearchColumnStringField[] scsf = SaleTicket.basic.tranId;
                        variables.salesOrderNumber = scsf[0].searchValue;
                        SearchColumnSelectField[] Field = SaleTicket.basic.entity;
                        RecordRef rr = Field[0].searchValue;
                        if (!string.IsNullOrEmpty(rr.internalId))
                           {
                             variables.customerNsInternalID = rr.internalId;
                           }
                        variables.customerIdIntergerPart = Convert.ToInt32(variables.salesOrderNumber.Substring((variables.salesOrderNumber.IndexOf("-") + 1)));
                        InsertSalesOrderRecords(variables);

                        }
                        }
                    }
                }

            }

回答1:


Not sure how to do it using C# and web services but this is how I did it using SuiteScript

var savedSearch = nlapiLoadSearch(recordType, searchId);
var resultset = savedSearch.runSearch();
var returnSearchResults = [];
var searchid = 0;
do {
    var resultslice = resultset.getResults(searchid, searchid + 1000);
    for ( var rs in resultslice) {
        returnSearchResults.push(resultslice[rs]);
        searchid++;
    }
} while (resultslice.length >= 1000);

return returnSearchResults;



回答2:


According to this answer, 1000 Records is a hard limit. Check the answers to this question for possible solutions to your issue.




回答3:


Here is pseudocode for it (I do mostly javascript, so this will be pseudo-pseudocode ;) )

b_keepLoop = true, b_internalId = false;

while (b_keepLoop){

var a_filters = [];
if(b_internalId){
   a_filters.push(new nlobjSearchFilter('internalidnumber', null, 'greaterthanorequalto',   i_lastTranId));
}

searchResults = nlapiSearchRecord('transaction', a_searchName[0], a_filters); //10 units
/**do whatever you want for your actual code**/
if (searchResults.length >= 1000) {
            i_lastTranId = searchResults[(searchResults.length - 1)].getId();
            b_internalId = true;
} 
else {
        b_keepLoop = false;
}


来源:https://stackoverflow.com/questions/25862630/how-to-read-more-than-1000-records-return-from-netsuite-search-results-in-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!