Search Filter Object Usage in SuiteScript
The Search Filter object enables refined query capabilities in SuiteScript, encapsulating search criteria.
The Search Filter object in SuiteScript is essential for creating custom search queries within NetSuite. By utilizing various properties of the Filter object, developers can specify search criteria dynamically, enabling more targeted information retrieval.
What is a Search Filter Object?
A Search Filter object encapsulates a search criterion that can be added to a search operation within NetSuite. It is created using the search.createFilter(options) method and integrated into either a new or existing Search object via search.create(options) or search.load(options).
Key Guidelines for Using the Filter Object
When using the Filter object, keep these guidelines in mind:
- Implicit AND Operator: NetSuite defaults to using an implicit
ANDoperator for multiple filters, rather than allowing for explicitANDandORexpressions. - Handling Null Values: To exclude results with null values for a specific field, set the
Filter.formulaproperty to@NONE@. - Checkbox Filters: For checkbox fields, utilize the
ISoperator with values ofT(true) orF(false) to filter for checked or unchecked values, respectively.
Syntax Example
The following code sample illustrates how to set up a search filter:
var mySearchFilter = search.createFilter({ name: 'entity', operator: search.Operator.ISEMPTY,});Methods and Properties
The Filter object has several important properties:
| Property Name | Type | Description |
|---|---|---|
options.name | string | Required. Specifies the name or internal ID of the search field. |
options.join | string | Optional. Join ID for the filter. |
options.operator | string | Required. The operator used for the filter, from the search.Operator enum. |
options.values | mixed | Optional. Values for the filter (can include strings, dates, booleans, etc.). |
options.formula | string | Optional. Formula for the filter. |
options.summary | string | Optional. Specifies a summary type for the filter. |
Error Handling
Be aware of potential error codes when using filtering:
- Invalid Operator: The error
SSS_INVALID_SRCH_OPERATORoccurs when an invalid operator is specified. - Invalid Summary Type: Error
SSS_INVALID_SRCH_SUMMARY_TYPindicates that the specified summary type is not valid to be used in the column.
Who This Affects
- Administrators: Responsible for setting up and managing saved searches.
- Developers: Implementing custom search functionality using SuiteScript.
- Accountants: Utilizing search filters for tailored financial reports.
Key Takeaways
- The Search Filter is crucial for building effective search queries in SuiteScript.
- Use
@NONE@for filtering out null values andISfor checkbox fields. - Always verify operator types and summary types to avoid errors.
Frequently Asked Questions (4)
How can I exclude null values using a Search Filter object in SuiteScript?
Can I use both 'AND' and 'OR' operators when specifying multiple filters in SuiteScript?
What operator should I use for filtering checkbox fields in SuiteScript?
What are common errors to look out for when using a Search Filter object?
Was this article helpful?
More in Searches
- Search for Sublist Line Fields With Dynamic Tables in NetSuite
Learn how to optimize search queries for sublist line fields in NetSuite using dynamic tables and SuiteQL.
- PagedData Object Members in NetSuite SuiteScript 2.0
PagedData provides efficient pagination for search results in SuiteScript, enabling effective handling of large data sets.
- Search Object Errors in SuiteScript for NetSuite
Understand common search object errors in SuiteScript for NetSuite and how to resolve them effectively.
- Error Handling in Searches with SuiteScript 2.0 Features
Gain insights into error handling in SuiteScript searches, including codes and common issues that arise when loading saved searches.
Advertising
Reach Searches Professionals
Put your product in front of NetSuite experts who work with Searches every day.
Sponsor This Category