Can we call a Saved Search in a Restlet instead of creating Saved Search Dynamically

Is there any way to call a Saved Search in a Restlet instead of creating a Dynamic Saved Search, because dynamically creating a Saved Search is a Time Consuming Work it pulls the data and read one by one and then send the data, is there any easy and less time taking time to pull the data,

Is there any way to pull directly CSV or Saved Search.

Beginner Asked on December 19, 2023 in SuiteScript.
Add Comment
1 Answer(s)

With N/search module, you can create a new saved search. You can also load a saved search which you have created through Netsuite UI.
But it does not solve your issue because even after loading the saved search, you’ll need to process the returned data one by one like array elements.

Rookie Answered on December 19, 2023.

When I was trying to retrieve 10000 Records from Netsuite through Saved Search then it stopped because it was taking too much time and due to Governance Usage limit Netsuite Stopped the process , is there any way to increase the time of download and download it fast.

on December 28, 2023.

The governance limit for suitescript is fixed and I am afraid you cannot change it. You can find the governance limit of each script type in the documentation.

We once wanted to perform complex operations in our User Event script so we found a way around. We created a schedule (you can also use map/reduce) script and used n/task module to call our user event script. The map reduce script & Schedule script has a higher governance usage limit.

The other thing is that when we use N/search module to create or load our saved search and process on records, it has a limit of fetching 1,000 records at a time. No more than that. You will either need to write a logic similar to pagination and store 10,000 records in your code somewhere and then start processing it or you will need to run your saved search 10 times for a 1,000 records.

on December 28, 2023.

You can get an array of all results by passing a search object to this function:


function getAllResults(osearch) {

let all = [];

let results = [];
let startIndex = 0;

let endIndex = 1000;

let pageSize = 1000;

do {

results = osearch.run().getRange({

start: startIndex,

end: endIndex

});

all = all.concat(results);

startIndex += pageSize;

endIndex += pageSize;

} while (results.length === pageSize);

return all;

}

on January 2, 2024.
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