Color Object Members for SuiteScript Workbook Module

Color objects in SuiteScript provide methods to define colors using RGBA values, enhancing the customization of workbook styles.

·2 min read·View Oracle Docs

TL;DR Opening

Color objects in SuiteScript allow developers to define colors for workbook elements using red, green, blue, and alpha (transparency) values. This capability is crucial for creating visually distinct and appealing outputs in NetSuite workbooks.

Overview of Color Object Members

The workbook.Color object in SuiteScript enables you to create and manipulate colors within a workbook. Here are the available members associated with this object:

Member NameTypeReturn Type/Value TypeSupported Script TypesDescription
Color.alphaPropertynumberServer scriptsThe opacity, or transparency, of the color.
Color.bluePropertynumberServer scriptsThe blue portion of the color.
Color.greenPropertynumberServer scriptsThe green portion of the color.
Color.redPropertynumberServer scriptsThe red portion of the color.

Creating a Color Object

You can create a new color object using the workbook.createColor(options) method. Here's an example that demonstrates the syntax for creating a color:

suitescript
1// Create a color object
2var myColor = workbook.createColor({
3 red: 255,
4 green: 192,
5 blue: 203,
6 alpha: 0.5
7});

Accessing Color Properties

Once a color object is created, you can access its properties directly. For instance, to retrieve the alpha value:

suitescript
var theAlpha = myColor.alpha;

Error Handling

While working with colors, it's important to ensure that the values for the alpha, red, green, and blue properties are within the required ranges to avoid errors:

  • Error Code: INVALID_ALPHA_VALUE
    • Thrown if the alpha value is not between 0 and 255.
  • Error Code: WRONG_PARAMETER_TYPE
    • Thrown if the value specified for any property is not a number.

Key Considerations

  • The color object is supported in server scripts, allowing for dynamic styling in workbook generation.
  • Ensure that alpha values are set correctly to avoid transparency issues in outputs.

Who This Affects

  • Developers: Those implementing or enhancing SuiteScript applications utilizing the workbook module.
  • Administrators: Users who configure or customize the workbooks for reporting or data visualization purposes.

Key Takeaways

  • Color objects facilitate custom styling in SuiteScript using RGBA values.
  • Proper handling of color property values is essential to avoid runtime errors.
  • The workbook module allows for dynamic content generation in NetSuite's SuiteScript environment.

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

Frequently Asked Questions (4)

What script types support the use of Color object members?
The Color object members are supported in server scripts within the SuiteScript environment.
How can I create a new color object using SuiteScript?
You can create a new color object using the `workbook.createColor(options)` method, specifying the red, green, blue, and alpha values in the options object.
What are the valid ranges for color property values in SuiteScript?
The values for `alpha`, `red`, `green`, and `blue` properties must be within the numerical range of 0 to 255 to avoid errors.
What happens if the alpha value is outside the range of 0 to 255?
An error with the code `INVALID_ALPHA_VALUE` will be thrown if the alpha value is not between 0 and 255.
Source: Color 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 Platform

View all Platform articles →