Aspect Object Members in SuiteScript for Workbook API

Aspect object members in SuiteScript define measures and types within the Workbook API for effective data handling.

·2 min read·View Oracle Docs

TL;DR Opening

The Aspect object members in SuiteScript facilitate the handling of data measures and types within the Workbook API, enhancing scripting flexibility and data interaction. Understanding these properties is crucial for effective script development.

What is the Aspect Object?

The Aspect object is part of the Workbook API, which allows developers to create and manipulate data visualizations directly in SuiteScript. By utilizing the Aspect object, you can define specific data measures and types necessary for your workbook operations.

What Members Does the Aspect Object Include?

The Aspect object includes several key members:

Member NameTypeReturn Type / Value TypeSupported Script TypesDescription
Aspect.measureworkbook.CalculatedMeasure or workbook.DataMeasureMeasure of the aspect.Server scriptsRepresents the measurement aspect of the object.
Aspect.typestringThe type of the aspect.Server scriptsSpecifies the kind of aspect using workbook.AspectType.

Syntax for Creating an Aspect

To create an Aspect object, you can utilize the following code structure, which highlights both basic and complete examples:

suitescript
1// Create a basic Aspect
2var myAspect = workbook.createAspect({
3 measure: myMeasure,
4});
5
6// Create a complete Aspect
7var myAspect = workbook.createAspect({
8 measure: myMeasure,
9 type: workbook.AspectType.COLOR
10});

How to Access Aspect Members

After creating an Aspect object, it’s possible to access its various properties, as shown here:

suitescript
1// Load a workbook and view an aspect in a Chart
2var myWorkbook = workbook.load({
3 id: myWorkbookId
4});
5var myAspect = myWorkbook.charts[0].series[0].aspect[0];
6
7log.audit({
8 title: 'Aspect type = ',
9 details: myAspect.type
10});
11log.audit({
12 title: 'Aspect measure = ',
13 details: myAspect.measure
14});

Error Handling

When working with the Aspect members, be aware of the following error code that may be thrown:

  • WRONG_PARAMETER_TYPE: This error occurs if the provided value for Aspect.measure is not of type workbook.CalculatedMeasure or workbook.DataMeasure.

Who This Affects

  • Developers: Ensures they can effectively utilize the Workbook API to create dynamic reports.
  • Administrators: Assists in managing workbook creation and data visualization tasks efficiently.

Key Takeaways

  • The Aspect object enhances data handling within the SuiteScript Workbook API.
  • Key properties include measure and type, defining how data is represented.
  • Error handling is crucial for preventing incorrect data types during variable assignments.

Frequently Asked Questions (4)

What script types support the Aspect object in SuiteScript?
The Aspect object in SuiteScript is supported in server scripts.
What error might occur when working with Aspect.measure, and how can it be avoided?
The WRONG_PARAMETER_TYPE error may occur if the value for Aspect.measure is not of type workbook.CalculatedMeasure or workbook.DataMeasure. To avoid this, ensure that the measure provided is of the correct type.
Can an Aspect object have both measure and type properties defined?
Yes, an Aspect object can have both measure and type properties defined. You can create a complete Aspect by specifying both properties, as shown in the example using workbook.createAspect with measure and type.
How do I access an Aspect object's properties in a SuiteScript workbook?
You can access an Aspect object's properties, such as type and measure, by first loading the workbook and then using chart series indexing to access the aspect. Use log.audit to display these properties, as seen in the provided example code.
Source: Aspect 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 General

View all General articles →