This topic contains 2 replies, has 0 voices, and was last updated by dc92974 6 years, 7 months ago.

  • Author
    Posts
  • #21324

    dc92974

    Has anyone else ran into this? We've had a ticket open with NetSuite for a long time and I'm surprised I can't seem to find anyone else talking about the issue.

    When we run saved searches in code we usually use a pattern that allows for more than 1000 rows. What we've discovered is that this results in some of the rows not being returned… sometimes :-(. We've duplicated the issue in 1.0 and 2.0. It seems to only happen on saved searches that have less than 1000 results and more than 150(ish). I also think we've only ran into it when searching the item record.

    Here's some 1.0 code that demos the issue. The nlapiSearchRecord will return the correct number of results, the slice version will be missing rows (sometimes).

    var savedSearchId = 1228;

    var x = getSearchResults(null, savedSearchId);

    nlapiLogExecution('DEBUG', 'Search results 1', x.length)

    var y = nlapiSearchRecord(null, savedSearchId);

    nlapiLogExecution('DEBUG', 'Search results 2', y.length)

    var stop = 'here';

    function getSearchResults(recordType, searchId) {

    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;

    }
    This is a cached copy. Click here to see the original post.

  • #21325

    Olivier Gagnon NC

    Yes, this has happened to me a few times. Filing a defect sometimes works, but sometimes you just need to change your filters and that fixes it. It's weird.

  • #21326

    dc92974

    I tried changing, adding and removing criteria but no luck. Was worth a shot though thanks.

You must be logged in to reply to this topic.