DataMeasure Object Members Reference in SuiteScript
The DataMeasure object in SuiteScript defines data measures for custom analytics with properties like aggregation and labels.
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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category