Search Filter Object Usage in SuiteScript

The Search Filter object enables refined query capabilities in SuiteScript, encapsulating search criteria.

·2 min read·1 views·View Oracle Docs

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 AND operator for multiple filters, rather than allowing for explicit AND and OR expressions.
  • Handling Null Values: To exclude results with null values for a specific field, set the Filter.formula property to @NONE@.
  • Checkbox Filters: For checkbox fields, utilize the IS operator with values of T (true) or F (false) to filter for checked or unchecked values, respectively.

Syntax Example

The following code sample illustrates how to set up a search filter:

suitescript
var mySearchFilter = search.createFilter({
name: 'entity',
operator: search.Operator.ISEMPTY,
});

Methods and Properties

The Filter object has several important properties:

Property NameTypeDescription
options.namestringRequired. Specifies the name or internal ID of the search field.
options.joinstringOptional. Join ID for the filter.
options.operatorstringRequired. The operator used for the filter, from the search.Operator enum.
options.valuesmixedOptional. Values for the filter (can include strings, dates, booleans, etc.).
options.formulastringOptional. Formula for the filter.
options.summarystringOptional. 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_OPERATOR occurs when an invalid operator is specified.
  • Invalid Summary Type: Error SSS_INVALID_SRCH_SUMMARY_TYP indicates 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 and IS for 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?
To exclude results with null values for a specific field, set the `Filter.formula` property to `@NONE@`.
Can I use both 'AND' and 'OR' operators when specifying multiple filters in SuiteScript?
NetSuite defaults to using an implicit 'AND' operator for multiple filters, and does not allow for explicit 'AND' and 'OR' expressions.
What operator should I use for filtering checkbox fields in SuiteScript?
For checkbox fields, use the 'IS' operator with values of 'T' (true) or 'F' (false) to filter for checked or unchecked values, respectively.
What are common errors to look out for when using a Search Filter object?
Common errors include 'SSS_INVALID_SRCH_OPERATOR' for invalid operators and 'SSS_INVALID_SRCH_SUMMARY_TYP' for invalid summary types.
Source: Syntax Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Platform

View all Platform articles →