Saved Searches in NetSuite is a powerful feature that enables users to create custom reports and searches to retrieve relevant data. It is a versatile tool that can be used for a variety of purposes, from managing inventory to tracking sales and customers. However, creating an efficient saved search requires careful planning and adherence to best practices. In this blog post, we will discuss some of the best practices to follow while creating saved searches in NetSuite.
Define the Purpose of the Search
Before creating a saved search, it is essential to define the purpose of the search. What is the information you are looking for? What are the fields and filters you need to include in the search? Defining the purpose of the search will help you create a more accurate and efficient search.
Use Simple Filters
When creating saved searches in NetSuite, it is essential to use simple filters. Simple filters including AND and OR operators and can be grouped using parentheses. Complex filters, on the other hand, use operators such as NOT, IN, BETWEEN, and CONTAINS, and can quickly become convoluted and hard to manage.
Limit the Number of Criteria
To create an efficient saved search, limiting the number of criteria used in the search is crucial. The more criteria you add to the search, the more time it will take to execute the search. Try to keep the number of criteria minimum and use simple filters to create a more efficient search.
Choose the Right Record Type
When creating a saved search, it is vital to choose the correct record type. Different record types have different fields and filters available, and choosing the wrong record type can result in an inaccurate or inefficient search. Make sure to choose the record type that contains the information you need to retrieve.
Use Joins Sparingly
Joins are used to link records together in a saved search. While joins can be helpful in creating more complex searches, they can also slow down the search execution time. It is essential to use joins sparingly and only when necessary.
In this example, the search type is set to “salesorder”, and a filter is applied to only include sales orders where the “mainline” field is true. Two columns are created using search.createColumn: one for the “tranid” field from the “salesorder” record, and another for the “entityid” field from the “customer” record, which is joined to the “salesorder” record using the join property.
Use Summary Types
NetSuite provides several summary types that can be used to summarize data in a saved search. Using summary types can help to reduce the number of results returned and make the search more efficient. Some of the common summary types include SUM, COUNT, AVERAGE, and MIN/MAX.
In this example, the search type is set to “salesorder”, and a filter is applied to only include sales orders with a status of “Fully Billed”. Three columns are created using search.createColumn: one for the transaction date with a summary type of “GROUP”, one for the total amount with a summary type of “SUM”, and one for the item joined record with a summary type of “COUNT”.
Optimize the Search
After creating a saved search, optimizing the search to improve its efficiency is essential. Optimization can involve adding indexes to the fields used in the search, using summary types to reduce the number of results returned, and limiting the number of criteria used in the search.
Test the Search
Before using the saved search, it is crucial to test the search to ensure it is accurate and efficient. Testing can involve running the search with different criteria, checking the results for accuracy, and measuring the search execution time. Testing can help to identify any issues with the search and allow for improvements to be made.
Following are some best practices, you can create more efficient and accurate saved searches in SuiteScript.
- Use specific criteria: Start by selecting specific criteria for your saved search. This will help ensure you get accurate results and avoid having too many records returned.
- Limit the columns: Only select the necessary columns for your search. This will help reduce the data returned and make the search more efficient.
- Use summary types: Summary types can group and summarize data in saved searches. They can help you quickly get an overview of the data and be especially useful for financial reports.
Conclusion
Saved Searches in NetSuite is a powerful tool to help users retrieve relevant data and create custom reports. By following the best practices outlined above, users can create more efficient and accurate saved searches that meet their needs. Remember to define the purpose of the search, use simple filters, limit the number of criteria, choose the right record type, use joins sparingly, use summary types, optimize the search, and test the search to ensure accuracy and efficiency.
About the Author
Fahad Latif
Senior Software Engineer - Folio3
Fahad Latif is a highly skilled and competent Netsuite developer dedicated to his work and passion for technology. In his free time, he enjoys indulging in the world of web series and books, allowing him to escape from the daily grind and expand his knowledge and imagination. His love for entertainment, combined with his technical expertise makes Fahad a well-rounded individual with a great appreciation for both technical and creative aspects of life.