SortByMeasure Object for Workbook Sorting in SuiteScript

The SortByMeasure object enables sorting by specific measures in SuiteScript, providing enhanced analytics capabilities.

·2 min read·View Oracle Docs

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:

MemberTypeReturn Type / Value TypeSupported Script TypesDescription
SortByMeasure.measureworkbook.CalculatedMeasure <br> workbook.DataMeasureworkbook.CalculatedMeasure <br> workbook.DataMeasureServer scriptsThe measure for the sort.
SortByMeasure.otherAxisSelectorworkbook.DescendantorSelfNodesSelector <br> workbook.PathSelector <br> workbook.DimensionSelectorworkbook.DescendantorSelfNodesSelector <br> workbook.PathSelector <br> workbook.DimensionSelectorServer scriptsThe selector for the axis not defined in the sort.
SortByMeasure.sortworkbook.Sortworkbook.SortServer scriptsThe 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:

suitescript
1// Example of creating a SortByMeasure object
2var mySortByMeasure = workbook.createSortByMeasure({
3 measure: myWorkbookMeasure, // previously created workbook.Measure object
4 otherAxisSelector: myAxisSelector, // previously created selector object
5 sort: mySort // previously created workbook.Sort object
6});

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, and sort.
  • 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?
The SortByMeasure object can use either workbook.CalculatedMeasure or workbook.DataMeasure as the measure for sorting.
Is the SortByMeasure object available for client scripts or only server scripts?
The SortByMeasure object is only available for use in Server Scripts as indicated in the documentation.
What error might be thrown if incorrect types are used with the SortByMeasure object?
If the measure property of the SortByMeasure object receives an incorrect type, the system will throw a WRONG_PARAMETER_TYPE error.
What method should be used to create a SortByMeasure object in SuiteScript?
To create a SortByMeasure object, use the workbook.createSortByMeasure(options) method with appropriate options.
Source: SortByMeasure 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 →