Period Object Members Overview in SuiteScript

Period Object Members in SuiteScript allow developers to manage time periods in queries, enhancing data retrieval capabilities.

·2 min read·View Oracle Docs

The Period Object in SuiteScript is crucial for managing time intervals within queries. It simplifies the process of creating conditions based on time, enhancing the overall querying capabilities. The object provides various properties to facilitate nuanced date handling in script-based queries.

What Are the Members of the Period Object?

The following table summarizes the key members available in the query.Period object:

MemberTypeReturn Type/Value TypeSupported Script TypesDescription
Period.adjustmentPropertystring (read-only)Client and server scriptsThe adjustment of the period. Uses values from the query.PeriodAdjustment enum.
Period.codePropertystring (read-only)Client and server scriptsThe code of the period. Utilizes values from the query.PeriodCode enum.
Period.typePropertystring (read-only)Client and server scriptsThe type of the period. Based on the query.PeriodType enum.

How to Create a Period Object

To instantiate a Period object, utilize the query.createPeriod(options) function. This method allows you to specify various attributes such as the period code, adjustment, and type. Here’s a basic example of creating a Period object:

suitescript
var myPeriod = query.createPeriod({
code: query.PeriodCode.LAST_PERIOD,
adjustment: query.PeriodAdjustment.ALL,
type: query.PeriodType.END
});

Example Usage in Query Conditions

Once you have created a Period object, it can be incorporated into the values parameter of Query.createCondition(options) or Component.createCondition(options). Below is an example of how it can be used within a condition:

suitescript
var myComplexCondition = myQuery.createCondition({
fieldId: 'trandate',
operator: query.Operator.BEFORE,
values: [myPeriod]
});

Important Notes

  • The adjustment property defaults to query.PeriodAdjustment.NOT_LAST unless specified otherwise.
  • It is logical to remember that the Period object is relevant both for client and server-side scripts, providing flexibility in your implementations.

Conclusion

Understanding the Period object in SuiteScript is vital for developers who need to manage time-based queries effectively. This object not only streamlines the querying process but also enhances the capabilities of script-based data manipulation.

Source: This article is based on Oracle's official NetSuite documentation.

Key Takeaways

  • The Period object simplifies handling time periods in queries.
  • It includes properties for adjustment, code, and type.
  • The object can be utilized in both client and server scripts for efficient data retrieval.

Frequently Asked Questions (4)

What script types are supported by the Period object in SuiteScript?
The Period object supports both client and server-side scripts, offering flexibility in script-based queries and conditions.
How is the adjustment property of a Period object set by default if not specified?
If not specified, the adjustment property defaults to 'query.PeriodAdjustment.NOT_LAST'.
How can I create a Period object for use in SuiteScript?
You can create a Period object using the query.createPeriod(options) function, where you specify attributes like period code, adjustment, and type.
How can the Period object be used in query conditions?
The Period object can be incorporated into the values parameter of Query.createCondition(options) or Component.createCondition(options), allowing you to use it within query conditions to manage time-based data retrieval.
Source: Period 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 General

View all General articles →