alyesmael22's Profile
Rookie
9
Points

Questions
3

Answers
1

  • Rookie Asked on July 28, 2022 in SuiteScript.

    You can use the following function:

    let objSearch = search.create({
                                type: ‘testSearchRecord’,
                                filters: [
                                    [‘filter1’],
                                    ‘AND’,
                                    [‘filter2’],
                                    ‘AND’,
                                    [‘filter3’]
                                ],
                                columns: [‘col1’, ‘col2’]
                            });
     let objSearchResult = getAllResults(objSearch);
    // this function get all result of search if it is more than 1000 records
    function getAllResults(s) {
            var results = s.run();
            var searchResults = [];
            var searchid = 0;
            do {
                var resultslice = results.getRange({
                    start: searchid,
                    end: searchid + 1000,
                });
                resultslice.forEach(function (slice) {
                    searchResults.push(slice);
                    searchid++;
                });
            } while (resultslice.length >= 1000);
            return searchResults;
        }
    • 2656 views
    • 4 answers
    • 0 votes