DataMeasure Object Members in SuiteScript Reference
The DataMeasure object in SuiteScript allows defining data measures with properties like aggregation and labels for custom analytics.
The DataMeasure object in SuiteScript provides a structured way to define data measures used within the workbook functionality of NetSuite. This object allows developers to utilize properties that detail the aggregation method, the expression, and labels associated with these measures.
Overview of DataMeasure Properties
The following table outlines the members of the workbook.DataMeasure object:
| Property Name | Return Type | Supported Script Types | Description |
|---|---|---|---|
DataMeasure.aggregation | string | Server scripts | Defines the aggregation method for the data measure. |
DataMeasure.expression | workbook.Expression | Server scripts | The single expression for the data measure. |
DataMeasure.expressions | workbook.Expression[] | Server scripts | An array of expressions for multiple-expression measures. |
DataMeasure.label | `string | workbook.Expression` | Server scripts |
Creating a DataMeasure Object
To create a DataMeasure object, the workbook.createDataMeasure(options) method is used. This method requires the following options:
aggregation: The method of aggregation (e.g.,DataCount).expression: A previously createdworkbook.Expressionobject, denoting the data used for calculations.label: A descriptive label for the measure.
Here is a sample syntax for creating a DataMeasure:
1// Add additional code2...3// myDataMeasure is a workbook.DataMeasure object4 5var myDataMeasure = workbook.createDataMeasure({6 aggregation: 'DataCount',7 expression: singleExpression, // previously created workbook.Expression8 label: 'MeasureLabel'9});10...11// Add additional codeSupported Module
The DataMeasure object is part of the N/workbook Module, which provides various functionalities for manipulating workbook objects within SuiteScript.
Error Handling
It's important to manage potential errors when interacting with the DataMeasure object. Some common error codes include:
INVALID_AGGREGATION: Thrown if the specified aggregation value is not part of theworkbook.Aggregationenum.WRONG_PARAMETER_TYPE: Thrown when the data type provided does not match the expected type (e.g., a string).
Key Considerations
- Ensure that expressions defined in
DataMeasurefollow the correct formatting and data types to avoid runtime errors. - Familiarize yourself with the
N/workbook Modulefor effective utilization of the DataMeasure object capabilities.
Key Takeaways
- The
DataMeasureobject helps define data measures for analytics in SuiteScript. - Key properties include
aggregation,expression, andlabel. - Proper error handling is essential for maintaining data integrity and functionality in scripts.
Frequently Asked Questions (4)
How can I create a DataMeasure object in SuiteScript?
What script types support the DataMeasure properties?
What are some common errors when using the DataMeasure object?
Which module in SuiteScript includes the DataMeasure object?
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.
