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.
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 Name | Type | Description | Supported Script Types |
|---|---|---|---|
Result.asMap() | Object | Returns the query result as a mapped object. | Client and server scripts |
Result.getValue(options) | `boolean | number | string |
Result.values | Array `<boolean | number | string |
Understanding the Methods
-
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.suitescript1var myCustomerQuery = query.create({2 type: query.Type.CUSTOMER3});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} -
Result.getValue(options)
This method retrieves a value at a given index from theResult.valuesarray, returning data in various types depending on the value stored.suitescriptvar 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()orgetValue()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.
Frequently Asked Questions (4)
Do I need specific permissions to use Result object members in SuiteScript?
Can Result object methods be used in both client and server scripts?
How does the Result.asMap() method simplify data manipulation in SuiteScript?
What types of values can be retrieved using Result.getValue(options)?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
