Duration Object Members in SuiteScript Reference

Duration object members provide essential parameters for defining time spans in SuiteScript, supporting server-side scripts and calculations.

·2 min read·View Oracle Docs

The Duration object in SuiteScript enables developers to define and manage duration periods effectively. It consists of specific members that facilitate handling time-related data within server-side scripts, thereby enhancing the scripting capabilities in NetSuite.

What Are the Duration Object Members?

The Duration object comprises two significant members:

Member NameTypeDescription
Duration.amountnumberThe amount that represents the duration.
Duration.unitsObjectThe units corresponding to the duration amount.

Property: Duration.amount

  • Type: number
  • Description: This property captures the numeric value representing the duration amount, such as days, hours, or minutes.
  • Supported Script Types: This property can be utilized in server scripts.
  • Error Handling: If there is an attempt to set the value of this property after the Duration object has been instantiated, the error code READ_ONLY_PROPERTY will be thrown.

Property: Duration.units

  • Type: Object
  • Description: This property contains the specific units that are applied to the duration amount, allowing flexibility in working with various time measurements such as seconds, minutes, hours, etc.
  • Supported Script Types: Like the amount property, this can also be used within server scripts.

Contextual Use

The Duration object members are primarily utilized within scripts that need to perform time calculations or when logging durations in user interfaces, workflows, or automated processes in NetSuite. For instance, if you are developing a scenario where task completion time is logged, using the Duration object supports precise tracking.

For more extensive practices and structural integration, refer to the N/workbook Module documentation. Utilizing these properties allows developers to build more robust and flexible scripts tailored to their business requirements.

Frequently Asked Questions (4)

Can the Duration.amount property in SuiteScript be modified after the object is created?
No, the Duration.amount property cannot be modified after the object is created. Attempting to do so will result in a READ_ONLY_PROPERTY error.
What are the supported script types for utilizing Duration object members in NetSuite?
The Duration object members, including the amount and units properties, can be utilized in server-side scripts within NetSuite.
How does the Duration.units property enhance time-related scripting in NetSuite?
The Duration.units property allows developers to specify the units for the duration amount, offering flexibility to work with various time measurements like seconds, minutes, and hours in server scripts.
Is the Duration object suitable for task completion time tracking in NetSuite scripts?
Yes, the Duration object is suitable for scenarios such as task completion time tracking, as it supports precise logging and calculation of time periods in scripts.
Source: Duration Object Members 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 Platform

View all Platform articles →