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.!

Rookie Asked on July 26, 2022 in SuiteScript.
Add Comment
4 Answer(s)

1000 governance points is exceedingly difficult to reach, even when reading search results.  You are likely doing something else very inefficient.

Intermediate Answered on July 26, 2022.

May be… It can be inefficient but I have achieved as per the requirement. but getting error when search returns more then 1000 records.. if you can suggest efficient so I can share the requirement as well.

see, actually – user will enter the From Date and End date and then on the basis of the date data will come.

Customer Cohort Total Average Jan-20 Feb-20 Mar-20 Apr-20
Jan-20  $            570,000.00  $            114,000.00  $  100,000.00  $    90,000.00  $  80,000.00  $  100,000.00
Feb-20  $            415,000.00  $              83,000.00  $                   –  $  200,000.00  $  50,000.00  $    65,000.00
Mar-20  $            270,000.00  $              54,000.00  $                   –  $                   –  $  50,000.00  $    20,000.00
Apr-20  $            340,000.00  $              68,000.00  $                   –  $                   –  $                 –  $    40,000.00

 

Cohort contain the all customer who have given the First Sale on respective month and then sales by the same customer for rest of the month.

Please suggest something efficient.. Thanks.!

on July 29, 2022.
Add Comment

It is odd that you are running into governance while reading search results unless your doing something else that consumes governance for each result.

It’s hard to make any recommendations on how to handle governance without viewing your code.

You may be able to optimize the script to reduce governance.

If you can’t optimize you are going to need to find a way to break up the processing between multiple runs.

1. You could use a map/reduce script that has a lot of advantages when processing large amounts of data.

2. You can use a scheduled script that can process results until governance runs low and then reschedule. You can query governance remaining with the N/runtime module.

Rookie Answered on July 26, 2022.

Understand Marvinroman – its hard to suggest and idea without viewing code but please see the requirement (above comment). I would  show  you or talk about my logic as well..

And I cant use map/reduce and scheduled script because the whole process is customize means I am doing it on suitelet so we do not have any option.

on July 29, 2022.
Add Comment

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

Thanks @Alyesmael22. will try this  or check whether its working or not.

Rookie Answered on July 29, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor