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.
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 Name | Type | Return Type/Value Type | Supported Script Types | Description |
|---|---|---|---|---|
Color.alpha | Property | number | Server scripts | The opacity, or transparency, of the color. |
Color.blue | Property | number | Server scripts | The blue portion of the color. |
Color.green | Property | number | Server scripts | The green portion of the color. |
Color.red | Property | number | Server scripts | The 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:
1// Create a color object2var myColor = workbook.createColor({3 red: 255,4 green: 192,5 blue: 203,6 alpha: 0.57});Accessing Color Properties
Once a color object is created, you can access its properties directly. For instance, to retrieve the alpha value:
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?
How can I create a new color object using SuiteScript?
What are the valid ranges for color property values in SuiteScript?
What happens if the alpha value is outside the range of 0 to 255?
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