Result Object Members for Query Results in SuiteScript

Result object members allow you to retrieve and manipulate query results in SuiteScript for effective data handling.

·2 min read·View Oracle Docs

The Result object members in SuiteScript play a crucial role in processing query results, enabling developers to efficiently access and utilize data from various records. The Result object represents a single row from the result set of a query, offering methods and properties that facilitate data handling.

What Are Result Object Members?

The following members are available for a query.Result object, which you can use in both client and server scripts.

Members Overview

Member NameTypeDescriptionSupported Script Types
Result.asMap()ObjectReturns the query result as a mapped object.Client and server scripts
Result.getValue(options)`booleannumberstring
Result.valuesArray `<booleannumberstring

Understanding the Methods

  1. Result.asMap()
    This method converts the query result into a JavaScript object where each key corresponds to the field ID or the alias used in the query. This enables easy access to individual data points within the result.

    suitescript
    1var myCustomerQuery = query.create({
    2 type: query.Type.CUSTOMER
    3});
    4var resultSet = myCustomerQuery.run();
    5for (var i = 0; i < resultSet.results.length; i++) {
    6 var mResult = resultSet.results[i].asMap();
    7 log.debug(mResult);
    8}
  2. Result.getValue(options)
    This method retrieves a value at a given index from the Result.values array, returning data in various types depending on the value stored.

    suitescript
    var value = currentResult.getValue({
    name: 'email'
    });

Practical Application

Using these Result object members effectively can streamline data retrieval in your SuiteScript applications. With Result.asMap(), transforming query results into objects can aid in the quick fetching of specific values, enhancing overall script performance. Furthermore, understanding how to use Result.getValue() allows for precise value extraction based on indexing, which can be particularly beneficial in complex data sets.

Key Considerations

  • Ensure that you identify the correct column names when using asMap() or getValue() to avoid errors.
  • Utilize these techniques to improve script readability and maintainability by reducing redundancy in data extraction code.

Who This Affects

  • Developers: Anyone involved in creating or maintaining SuiteScript applications.
  • Administrators: Those managing script deployments or system integrations reliant on data queries.

Key Takeaways

  • The Result object members are essential for manipulating query results in SuiteScript.
  • Use asMap() for easy data manipulation and access in mapped format.
  • Ensure precise indexing when using getValue(options) to retrieve information accurately.

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

Frequently Asked Questions (4)

Do I need specific permissions to use Result object members in SuiteScript?
The article does not specify permissions needed to use Result object members in SuiteScript. It is advisable to ensure you have appropriate permissions for creating and running queries.
Can Result object methods be used in both client and server scripts?
Yes, the Result object methods such as `asMap()` and `getValue(options)` can be used in both client and server scripts.
How does the Result.asMap() method simplify data manipulation in SuiteScript?
The Result.asMap() method converts the query result into a JavaScript object, allowing easy access to data points with field IDs or aliases as keys. This facilitates transforming data into a more accessible format for manipulation.
What types of values can be retrieved using Result.getValue(options)?
The Result.getValue(options) method can retrieve values of the type boolean, number, string, Date, or null, depending on the value stored at the specified index.
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 Platform

View all Platform articles →