Color Object Members for SuiteScript Workbook Module
Color objects in SuiteScript define colors for workbook elements using RGBA values, enabling enhanced customization. TL;DR Opening
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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category