Legend Object Members for SuiteScript Workbook Integration

Understand the properties of the Legend object in SuiteScript for workbooks, including axes and sort definitions.

·2 min read·View Oracle Docs

The Legend object in SuiteScript provides several members that are essential for charting within workbooks. These members allow developers to manage chart axes, data dimensions, and sort definitions, enhancing visual data representation and analysis.

What Members Does the Legend Object Include?

The Legend object provides the following key members:

Member NameTypeSupported Script TypesDescription
Legend.axesworkbook.ChartAxis[]Server scriptsRepresents the axes of the legend.
Legend.rootworkbook.DataDimension | workbook.SectionServer scriptsRefers to the section or data dimension for the Y-axis.
Legend.sortDefinitionsworkbook.SortDefinition[]Server scriptsContains the sort definitions associated with the legend.

Error Handling

When working with properties of the Legend object, be aware of potential errors:

  • Error Code: WRONG_PARAMETER_TYPE
    • Thrown If: The value specified for a property is not a valid workbook.ChartAxis.

Code Sample

Below is an example to demonstrate how you might access the Legend.axes member of a workbook:

suitescript
1// Add additional code
2...
3// View Legend.axes in a Chart
4var myWorkbook = workbook.load({
5 id: myWorkbookId
6});
7
8log.audit({
9 title: 'Legend.axes = ',
10 details: myWorkbook.charts[0].legend.axes
11});
12...
13// Add additional code

This example illustrates the syntax to access and log the legend axes of a chart within a workbook, enhancing your ability to customize data visualizations in NetSuite.

Additional Context

For more detailed implementations, consider referring to the N/workbook Module, where further examples and complete scripts are available.

Related Resources

  • [N/workbook Module]: This module includes additional properties and methods related to workbook functionalities in SuiteScript.
  • [SuiteScript 2.x Script Types]: An overview of various script types supported in SuiteScript, critical for understanding the context of the Legend object usage.

Source: This article is based on Oracle's official NetSuite documentation.

Key Takeaways

  • The Legend object in SuiteScript provides essential members for charts.
  • Key members include axes, root dimensions, and sort definitions.
  • Proper error handling is crucial when dealing with object properties.
  • Accessing Legend properties enhances the customization of data visualizations.

Frequently Asked Questions (4)

Does the Legend object support client scripts in SuiteScript?
No, the Legend object members are supported only in server scripts as per the provided documentation.
What should I be careful of when working with Legend object properties?
You should be aware of potential errors such as 'WRONG_PARAMETER_TYPE' which occurs if a property value is not a valid workbook.ChartAxis.
Can Legend.axes represent multiple axes in a chart?
Yes, Legend.axes can represent multiple axes as it is an array of workbook.ChartAxis.
Is there an example of how to access the Legend.axes member in a script?
Yes, the article provides a code example that demonstrates accessing and logging the 'Legend.axes' member of a chart within a workbook using SuiteScript.
Source: Legend 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 →