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.
Source: This article is based on Oracle's official NetSuite documentation.
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 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