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

前端 未结 3 617
北恋
北恋 2021-01-24 14:00

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 som

相关标签:
3条回答
  • 2021-01-24 14:14

    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;
    
    0 讨论(0)
  • 2021-01-24 14:17

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

    0 讨论(0)
  • 2021-01-24 14:27

    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;
    }
    
    0 讨论(0)
提交回复
热议问题