RE: How to handle when we get more result form saved search in suitelet and get SSS_USAGE_LIMIT_EXCEEDED

Hello Everyone,

I have created a suitelet where I have to field “Start Date” and “End Date”. on the basis of the this two date the amount of sales order is coming via saved search. but when script consumed 1000 governance unit it shows error “SSS_USAGE_LIMIT_EXCEEDED”.

So how can we handle it in suitelet.?

Please guide and help…..

Thanks.!

Ajay_K_Mandloi Rookie Asked on July 26, 2022 in SuiteScript.
Add Comment
4 Answers

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;
    }
Rookie Answered on July 28, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.