Search Column Syntax for SuiteScript 2.x in NetSuite

Search column syntax in SuiteScript 2.x allows encapsulation of fields in NetSuite searches, enhancing data retrieval capabilities.

·2 min read·View Oracle Docs

The search column syntax in SuiteScript 2.x encapsulates a single search column within a search.Search object. By using the methods and properties provided by the Column object, developers can easily get or set the properties of search columns. This functionality is crucial for building customized search queries that can retrieve the specific data required from the NetSuite database.

Creating Search Column Objects

To create a search column object, utilize the search.createColumn(options) method and then incorporate it into a search.Search object. You can create a search object using either:

  • search.create(options) to generate a new search, or
  • search.load(options) to load an existing search.

Additionally, you can pass a Column object as an argument to methods such as Result.getValue(column) and Result.getText(column) to obtain specific values from the search results.

Supported Script Types

The search column syntax is compatible with both client and server scripts, making it versatile in various development scenarios.

Core Methods and Properties

For an in-depth understanding of the methods and properties available to the Column object, refer to the Column Object Members documentation.

Example Syntax

The following code snippet illustrates the syntax for creating a search column. Note that it represents a structural example rather than a functional one. For complete usage examples, consult the N/search Module Script Samples.

suitescript
1// Example of creating a search column
2search.create({
3 type: search.Type.TRANSACTION,
4 columns: [
5 'trandate',
6 'amount',
7 'entity',
8 'entity.firstname',
9 'entity.email',
10 search.createColumn({
11 name: 'formulatext',
12 formula: "{lastname}||', '||{firstname}"
13 })
14 ]
15 // The resulting output would format the name as: Last Name, First Name
16});

Conclusion

By mastering the use of search columns in SuiteScript 2.x, developers can effectively customize data retrieval, tailoring search results to meet specific business needs and workflows. Understanding the syntax and capabilities enhances the overall efficiency of working within the NetSuite environment.

Source: This article is based on Oracle's official NetSuite documentation.

Key Takeaways

  • Search columns encapsulate individual fields in NetSuite search results.
  • The syntax enables developers to create custom search queries for tailored data output.
  • Supports both client and server scripts, ensuring versatility in implementation.

Frequently Asked Questions (4)

How can I create a custom search column in SuiteScript 2.x?
To create a custom search column, use the `search.createColumn(options)` method and incorporate it into a search.Search object using either `search.create(options)` for new searches or `search.load(options)` for existing ones.
Is search column syntax available for both client and server scripts in NetSuite?
Yes, the search column syntax is compatible with both client and server scripts, allowing flexibility in various development scenarios.
Can I use a search column in methods that retrieve specific search result values?
Yes, you can pass a Column object to methods like `Result.getValue(column)` and `Result.getText(column)` to retrieve specific values from the search results.
What is the purpose of using the `formulatext` feature in search columns?
The `formulatext` feature allows for custom formatting within search columns, such as combining and formatting fields like last name and first name into a single field.
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 Searches

View all Searches articles →