Set and Retrieve Date and Time Field Values in NetSuite

Updated for NetSuite 2026.2; date and time field APIs and governance guidance remain unchanged. TL;DR As of NetSuite 2026.2, the setFormattedValue() and

·2 min read·100 views·View Oracle Docs

TL;DR

As of NetSuite 2026.2, 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

javascript
setFormattedValue('QUESTION_CODE', 'ANSWER_CODE', 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:

javascript
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 TypeUsage Units
Transaction records10 units
Custom records2 units
All other records5 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.

Frequently Asked Questions (4)

Are setFormattedValue() and getParsedValue() available for both client-side and server-side scripts in NetSuite CPQ Configurator?
Yes. The article states both functions can be employed across client-side and server-side scripts and are introduced for use within NetSuite CPQ Configurator (version 1.9.0).
Do I need to convert JavaScript Date objects to strings before calling setFormattedValue()?
No. setFormattedValue() converts a JavaScript Date object into the string format expected by the answer record, so you can pass a Date object directly (for example, new Date()).
How do setFormattedValue() and getParsedValue() behave when used with non-date field types?
When used with other field types, their behavior aligns with setValue() and getValue(), providing consistency across different data types. They therefore act like the standard set/get methods for non-date fields.
What are the governance usage units for server-side actions in the CPQ Configurator and how many total units are available for an action?
Usage units vary by record type: transaction records consume 10 units, custom records consume 2 units, and all other records consume 5 units. A total of 927 usage units are available for a server-side action due to the overhead needed to initiate the action, which is important for optimizing script performance.

Weekly Update History (1)

NetSuite CPQadded

Added the following entries: Include Double Quotes in Rule String Values Match Any or All Selected Answer Values Using Rules Changes to the Placeholders for Retrieving Address Information

View Oracle Docs
Source: Set and Retrieve Date and Time Field Values Using Scripts — 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 SuiteScript

View all SuiteScript articles →