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
battk
10/11/2019, 1:25 PM
generally the answer is to make the search as simple as possible
battk
10/11/2019, 1:26 PM
you can try sharing the search and related code in case there is something obvious that can be done
v
Viraj Shinde
10/11/2019, 2:14 PM
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
battk
10/11/2019, 2:17 PM
you would need to share stuff for a chance at better advice
v
Viraj Shinde
10/11/2019, 2:47 PM
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.
Viraj Shinde
10/11/2019, 2:49 PM
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.