Period Object Members Overview in SuiteScript
Period Object Members in SuiteScript manage time periods in queries, enhancing data retrieval efficiency.
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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
- Enhancements to SuiteScript User Role Context Clarification
SuiteScript updates clarify the user and role contexts for script executions, improving deployment understanding and management.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category