What's the benefit of creating Saved Searches via ...
# suitescript
j
What's the benefit of creating Saved Searches via Suitescript? I've been using Saved Searches in UI only, and now I'm thinking I may resolve more complex scenarios if I learn Suitescript.
s
The one specific advantage I know of for scripting saved searches vs. using pre-defined saved searches, is that when using multiple formula fields of the same type, it is much easier to define the search via script. That said, scripting also allows you to use the search module and SuiteQL, which, if you aren’t afraid of SQL, give you much much more flexibility. You can define queries that are simply impossible with any single saved search, and I have found the performance of SuiteQL to be much better than saved searches. Much of that can also be achieved using the new Analytics Workbooks, though, so if you have no reason to use a script, you may want to start by learning about those instead. The real power of scripting comes in being able to create dynamic filters, and manipulate results or do something with the search results. If you just want a report, but with more flexibility than saved searches, the workbooks should meet that need.
👍 3
s
Another key reason to use searches in script is any situation where we do not want end users to change the search.
s
@Shawn Talbert That’s a good point. I was mostly focusing on the areas of what can/can’t be done. Whether or not one should use a UI defined search is also an important issue. I sometimes release scripts alongside an “audit” UI-defined saved search which is identical, so that users can preview what data a script will be processing before it happens. If a user accidentally modifies that search, which they shouldn’t, it won’t affect the script.
j
We’ve been considering this for deploying versioned Netsuite infrastructure. When you use a database migration library, generally you some state that is the
version
of the database state, then you have an
Up()
and a
Down()
to move through different versions of your schema. We’re using SDF to box up saved searches (and corresponding restlets) in account customization packages, but eventually we walk into situations where the dependency chain of a saved search includes very account specific piece of netsuite infrastructure (think: Non Profit Bundle stuff), and it might be beneficial to have some conditional code when creating/updating saved searches. Just to be clear, we’re not doing it right now, but it’s something that we’re investigating.