Set and Retrieve Date and Time Field Values in NetSuite
Learn how to effectively set and retrieve date and time field values using scripting functions in NetSuite CPQ Configurator.
TL;DR
The setFormattedValue() and getParsedValue() functions are designed for efficiently setting and retrieving date and time values in NetSuite CPQ Configurator (version 1.9.0). These functions facilitate easier handling of date formats within your scripts.
How Do setFormattedValue() and getParsedValue() Work?
Introduced specifically for use within the NetSuite CPQ Configurator, the setFormattedValue() function converts a JavaScript Date object into a string format that matches the expectations of the answer record in NetSuite. Here’s how to use it:
Setting Date and Time
setFormattedValue('QUESTION_CODE', 'ANSWER_CODE', "text-purple-400">new Date());This line of code will set the specified value using the current date and time. Ensure that you replace QUESTION_CODE and ANSWER_CODE with the actual reference codes pertinent to your implementation.
Retrieving Date and Time
To retrieve a date and time value back as a JavaScript Date object, utilize the getParsedValue() function:
getParsedValue('QUESTION_CODE', 'ANSWER_CODE');This method helps in managing date formats more seamlessly, allowing developers to work within the JavaScript environment directly without conversion hassles.
Both functions are versatile and can be employed across both client-side and server-side scripts. When used with other field types, their behavior aligns with setValue() and getValue(), providing consistency across different data types.
Understanding Governance and Usage Units
In the context of the NetSuite CPQ Configurator, keep in mind the governance usage units for server-side actions. Below is a brief overview of how usage units are structured based on record type:
| Record Type | Usage Units |
|---|---|
| Transaction records | 10 units |
| Custom records | 2 units |
| All other records | 5 units |
When executing server-side actions, a total of 927 usage units are available due to the overhead needed to initiate the action. Understanding these limits is pivotal for optimizing script performance within NetSuite.
Who This Affects
- Developers: Implementing date and time handling in scripts.
- Administrators: Overseeing script performance and governance limits.
- NetSuite CPQ Users: Utilizing date and time fields within configurations.
Key Takeaways
- Use
setFormattedValue()to set date and time values in an expected string format. - Employ
getParsedValue()to retrieve date and time as JavaScript Date objects. - Understand governance limits and usage units for effective script management.
- The functions can be used for both client-side and server-side scripting tasks efficiently.
Source: This article is based on Oracle's official NetSuite documentation.
Frequently Asked Questions (4)
Are `setFormattedValue()` and `getParsedValue()` functions specific to any NetSuite version?
Is it necessary to convert date values when using `setFormattedValue()` and `getParsedValue()`?
Do `setFormattedValue()` and `getParsedValue()` require any feature flags to be enabled?
What are the usage units for executing server-side actions using these functions?
Was this article helpful?
More in SuiteScript
- N/https Module: Binary File Support in NetSuite 2025.2
NetSuite 2026.1 adds binary file support to N/https for streamlined file handling.
- Attach and Detach Operations in NetSuite 2026.1
Attach and detach operations for record relationships in NetSuite enhance data management and connectivity.
- Create-Form Operation in NetSuite 2026.1 REST Web Services
Create-form operation in NetSuite 2026.1 APIs streamlines record creation and enhances efficiency.
- Improved Execution Log Support in NetSuite 2026.1
Improved execution log support in NetSuite 2026.1 aids debugging and performance tracking for developers.