SortByMeasure Object for Workbook Sorting in SuiteScript
The SortByMeasure object enables sorting by specific measures in SuiteScript, providing enhanced analytics capabilities.
The SortByMeasure object is crucial for developers creating sorts based on measures in NetSuite workbooks. This object allows you to define the sorting behavior of data within reports, creating a more dynamic and insightful analytical environment.
What Members Are Available in SortByMeasure?
The SortByMeasure object comprises several members, each serving specific purposes in sorting functionality. Below is a table detailing these members:
| Member | Type | Return Type / Value Type | Supported Script Types | Description |
|---|---|---|---|---|
SortByMeasure.measure | workbook.CalculatedMeasure <br> workbook.DataMeasure | workbook.CalculatedMeasure <br> workbook.DataMeasure | Server scripts | The measure for the sort. |
SortByMeasure.otherAxisSelector | workbook.DescendantorSelfNodesSelector <br> workbook.PathSelector <br> workbook.DimensionSelector | workbook.DescendantorSelfNodesSelector <br> workbook.PathSelector <br> workbook.DimensionSelector | Server scripts | The selector for the axis not defined in the sort. |
SortByMeasure.sort | workbook.Sort | workbook.Sort | Server scripts | The sort to use for ordering the data. |
How Do You Create a SortByMeasure Object?
To instantiate a SortByMeasure object, utilize the workbook.createSortByMeasure(options) method. Below is a sample syntax illustrating how this can be achieved:
1// Example of creating a SortByMeasure object2var mySortByMeasure = workbook.createSortByMeasure({3 measure: myWorkbookMeasure, // previously created workbook.Measure object4 otherAxisSelector: myAxisSelector, // previously created selector object5 sort: mySort // previously created workbook.Sort object6});Supported Script Types
The SortByMeasure object is available for use in Server Scripts. Developers may explore more about script types in the SuiteScript 2.x documentation.
Error Handling
Developers should be aware of the potential errors that may arise when utilizing the SortByMeasure object. For instance, if the SortByMeasure.measure property receives a value that is not a valid workbook.CalculatedMeasure or workbook.DataMeasure, the system will throw a WRONG_PARAMETER_TYPE error. This feature ensures that only the correct types are employed, enhancing robustness in script execution.
Summary
The SortByMeasure object is instrumental when organizing the data in workbooks, empowering developers to create more effective and user-friendly reports while leveraging defined measures for precise analytics. Being versed in how to properly implement and manage this object is essential for maximizing the functionality of SuiteScript in NetSuite workbooks.
Key Takeaways
- The SortByMeasure object is vital for defining sorts by measures in NetSuite workbooks.
- Three key members are utilized:
measure,otherAxisSelector, andsort. - Correct parameter types are critical to avoid errors during execution.
- This object is designed for Server Scripts within SuiteScript.
Source: This article is based on Oracle's official NetSuite documentation.
Frequently Asked Questions (4)
What types of measures can be used with the SortByMeasure object?
Is the SortByMeasure object available for client scripts or only server scripts?
What error might be thrown if incorrect types are used with the SortByMeasure object?
What method should be used to create a SortByMeasure object in SuiteScript?
Was this article helpful?
More in Platform
- Style Object Members for Workbook API in NetSuite
The Style object provides customizable properties for workbook formatting in NetSuite, enhancing report and visualization functionality.
- Asynchronous HTTP Requests with SuiteScript Promises
Use SuiteScript to send asynchronous HTTP requests with promises for efficient error handling and response processing.
- Setting Sublist Field Values in SuiteScript
Set values for sublist fields in SuiteScript using the setSublistValue method. Understand required parameters and error handling.
- In This Help Topic
Explore N/log module guidelines, log levels, and script execution logs for efficient logging in SuiteScript.
Advertising
Reach Platform Professionals
Put your product in front of NetSuite experts who work with Platform every day.
Sponsor This Category