Is it better to call a saved search or write the s...
# suitescript
r
Is it better to call a saved search or write the search in the script? which practice should one follow?
r
I think,Write the saved search in script is the best practice.
p
It depends, I normally create the saved search in the UI then reference it. If I need to update the filter or add a column, I don't need to touch my script. I will just update the saved search. The added benefit of having a saved search in the UI first is that you can see the result right away without a single line of script. If the search is straightforward with a couple of columns and filters, I do it in the script right away.
r
Yeah that's what's bugging me. One shouldn't be touching the script in production that often. So adding a new filter in saved search is a better way. Or so I got told. Just wanted to confirm once. I prefer to write the code though. Bcz in my mind if one accidentally deletes or edits a saved search it could cause multiple issues.
d
Limit access to the search, don't allow the audience to edit and/or use a naming convention for anything which is utilised by scripts.
m
Source control. Saved searches in code can be versioned. I find that once a problem is solved going back and tweaking saved search criteria and columns doesn’t happen that often. If I need to change a search, then I’m changing business logic and I want to capture that change in version control as well as any approvals and reviews that are needed prior to deploying that change to production.
r
thank you for all your inputs, they are insightful.
s
The search will run faster if already stored and loaded rather than dynamically created in code (as long as you are not loading it to modify it). Netsuite support will tell you this if you raise cases on script search execution times
👍 1