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.
Source: This article is based on Oracle's official NetSuite documentation.
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 Platform
- Asynchronous HTTP Requests with SuiteScript Promises
Use SuiteScript to send asynchronous HTTP requests with promises for efficient error handling and response processing.
- In This Help Topic
Explore N/log module guidelines, log levels, and script execution logs for efficient logging in SuiteScript.
- Style Object Members for Workbook API in NetSuite
The Style object provides customizable properties for workbook formatting in NetSuite, enhancing report and visualization functionality.
- Number Formatter Object Members in SuiteScript
The Number Formatter object in SuiteScript formats numbers to strings, supporting custom separators and precision settings.
Advertising
Reach Platform Professionals
Put your product in front of NetSuite experts who work with Platform every day.
Sponsor This Category