I'm trying to search through our customers list to...
# suitescript
v
I'm trying to search through our customers list to fetch a subset of customers based on the filters provided on our sitebuilder website. It is a 2.0 search that is executed in a 2.0 Suitelet service. The issue is that it takes a really long time (> 1min) to fetch the results even though hardly 30-40 results are returned. How can I speed up my search so that the user doesn't have to wait for such a long time?
b
generally the answer is to make the search as simple as possible
you can try sharing the search and related code in case there is something obvious that can be done
v
Nothing fancy in the code as such, I'm just setting some filters and columns and pushing the results in an array which I'm sending back to the front-end. Also, for every result, I'm processing the companyname string value by using split() and setting a part of the string in a property of the result object. There's no other processing that happens in the script apart from that.
b
you would need to share stuff for a chance at better advice
v
Never mind, I found the issue. I had made some optimizations to my script earlier today but seems like I had uploaded an older version of the script to the file cabinet. Silly mistake.
The issue in my old script: I was fetching selectOptions of a field in a function and that function was accidentally being called in the resultSet loop when it should have been called outside the loop. That slowed down everything.