Period Object Members Overview in SuiteScript
Period Object Members in SuiteScript allow developers to manage time periods in queries, enhancing data retrieval capabilities.
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:
| Member | Type | Return Type/Value Type | Supported Script Types | Description |
|---|---|---|---|---|
| Period.adjustment | Property | string (read-only) | Client and server scripts | The adjustment of the period. Uses values from the query.PeriodAdjustment enum. |
| Period.code | Property | string (read-only) | Client and server scripts | The code of the period. Utilizes values from the query.PeriodCode enum. |
| Period.type | Property | string (read-only) | Client and server scripts | The 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:
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:
var myComplexCondition = myQuery.createCondition({ fieldId: 'trandate', operator: query.Operator.BEFORE, values: [myPeriod]});Important Notes
- The
adjustmentproperty defaults toquery.PeriodAdjustment.NOT_LASTunless specified otherwise. - It is logical to remember that the
Periodobject 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.
Key Takeaways
- The
Periodobject 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?
How is the adjustment property of a Period object set by default if not specified?
How can I create a Period object for use in SuiteScript?
How can the Period object be used in query conditions?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
