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.
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 SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
