N/Search Module Result Object Members for SuiteScript

The N/search module provides valuable tools for creating searches, including Result object members that handle search results dynamically.

·2 min read·View Oracle Docs

The N/search module in NetSuite allows developers to create, run, and analyze searches on-demand or from saved queries. It is particularly useful for finding specific records based on defined criteria, returning extensive results, and pagination for larger datasets. This article explains the functionality of the Result object members found within the N/search module.

What is the Result Object?

The Result object encapsulates a single row of search results from a NetSuite query. It provides methods and properties that allow developers to retrieve specific data from each result record.

Core Functionalities

The Result object primarily supports two methods that are crucial in accessing data:

  • getText(column): Returns the text value for a specific column, useful when the field is of a select type.
  • getValue(options): Retrieves the value of a specified return column, allowing access to both formula and standard field values.

Properties of the Result Object

The following table summarizes the properties of the Result object that can be accessed in scripts:

Property NameReturn TypeDescription
columnssearch.Column[]Array of Column objects for the results returned in the search result row.
idstringThe internal ID for the record returned in a search result row.
recordTypestringThe type of record that is returned in the search result row.

Handling Search Results

Using the Result object effectively can dramatically enhance how your scripts retrieve and manipulate data. Here is a simple implementation example:

javascript
1// Sample search execution using the N/search module
2require(['N/search'], function(search) {
3 var mySearch = search.create({
4 type: search.Type.TRANSACTION,
5 columns: ['trandate', 'amount', 'entity']
6 });
7
8 mySearch.run().each(function(result) {
9 var transactionDate = result.getValue({
10 name: 'trandate'
11 });
12 var amount = result.getValue({
13 name: 'amount'
14 });
15 log.debug('Transaction Date: ' + transactionDate + ', Amount: ' + amount);
16 return true; // Continue to the next result
17 });
18});

Best Practices for Using Result Objects

  • Pagination: When dealing with large datasets, utilize pagination to effectively manage and retrieve results without overloading the system.
  • Efficient Queries: Always limit your searches by setting filters and columns to ensure the efficiency of your queries.

Who This Affects

This documentation is particularly relevant for:

  • Developers: Need to implement search functionalities in SuiteScript.
  • Administrators: Want to understand how to utilize search results for reporting and analysis.

Key Takeaways

  • The Result object is critical for accessing search results in NetSuite’s N/search module.
  • Use getText and getValue methods to dynamically retrieve data from search results.
  • Implementing efficient pagination and filters can significantly enhance the performance of your searches.

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

Frequently Asked Questions (4)

How does the Result object handle select type fields in search results?
The Result object provides the `getText(column)` method, which returns the text value for a specific column. This method is particularly useful for fields of a select type, allowing you to retrieve the display text of the field.
Is the Result object used for both on-demand and saved searches in SuiteScript?
Yes, the Result object is used to encapsulate a single row of search results from both on-demand and saved queries in SuiteScript, offering methods to retrieve specific data from each result record.
What is the role of the 'columns' property in the Result object?
The 'columns' property in the Result object is an array of Column objects representing the results returned in a search result row. It helps in identifying which columns are part of the search.
What advantage does using pagination with the N/search module offer?
Utilizing pagination with the N/search module allows for the effective management and retrieval of large datasets, preventing system overload and improving search performance.
Source: Result Object Members 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 →