Component Object Members for Query in SuiteScript
The Component Object Members enable dynamic query creation in SuiteScript, facilitating joins, conditions, and sorting for enhanced data retrieval.
TL;DR
The Component Object Members provide a robust framework for creating query components in SuiteScript. They allow developers to define joins, conditions, and sorting operations, enhancing the efficiency of data retrieval in NetSuite applications.
What Are Component Object Members?
Component Object Members are methods and properties associated with the query.Component object in SuiteScript. These components serve as building blocks for constructing complex queries, allowing for efficient manipulation and retrieval of data from NetSuite's databases. Each new component can be thought of as an extension or a child to the prior component, encapsulating relationships within the query.
How Do Component Object Members Work?
The following members are utilized to define various aspects of a query component:
| Member Name | Type | Return Type | Supported Script Types | Description |
|---|---|---|---|---|
autoJoin(options) | Method | query.Component | Client and server scripts | Creates a join relationship automatically based on record types. |
createColumn(options) | Method | query.Column | Client and server scripts | Generates a query result column based on the component. |
createCondition(options) | Method | query.Condition | Client and server scripts | Defines a filtering condition based on the component. |
createSort(options) | Method | query.Sort | Client and server scripts | Establishes a sort order based on the component. |
join(options) | Method | query.Component | Client and server scripts | An alias for autoJoin, creates a join relationship. |
joinFrom(options) | Method | query.Component | Client and server scripts | Creates an explicit directional join from another component. |
joinTo(options) | Method | query.Component | Client and server scripts | Creates an explicit directional join to another component. |
child | Property | Object | Client and server scripts | Holds child components as key-value pairs. |
parent | Property | String | Client and server scripts | Represents the parent component. |
source | Property | String | Client and server scripts | States the source query type of the component, set during a directional join. |
target | Property | String | Client and server scripts | Represents the target query type, set during a join. |
type | Property | String | Client and server scripts | Indicates the query type of the component. |
How to Use These Members?
- Creating Initial Query: Start with the root component using
query.create(options), defining your initial query type. - Building Joins: Use
Query.autoJoin(options)for the initial join, then utilizeComponent.autoJoin(options)orComponent.join(options)for subsequent joins. - Adding Columns and Conditions: You can dynamically create columns and conditions with
createColumnandcreateCondition, expanding your query's capabilities. - Sorting Results: Implement
createSortto establish how the results are sorted based on your criteria.
Important Notes
- Governance: There are no specific governance limits associated with these methods.
- Error Handling: Be mindful of error codes, such as
RELATIONSHIP_ALREADY_USED, which indicates that a specified join relationship is already defined.
Who This Affects
- Developers: Those scripting in SuiteScript for custom applications within NetSuite.
- Administrators: Users managing data retrieval processes and optimizing database queries.
Key Takeaways
- Component Object Members enable flexible data queries in SuiteScript.
- Using these members, you can easily create joins, column definitions, and sort conditions.
- Proper understanding can significantly enhance data retrieval performance in NetSuite applications.
Frequently Asked Questions (4)
Do I need to enable a feature flag to use Component Object Members in SuiteScript?
Can I use Component Object Members with existing database queries in NetSuite?
Are there governance limits associated with using Component Object Members for queries?
What script types support the use of Component Object Members for queries?
Was this article helpful?
More in Platform
- Style Object Members for Workbook API in NetSuite
The Style object provides customizable properties for workbook formatting in NetSuite, enhancing report and visualization functionality.
- Asynchronous HTTP Requests with SuiteScript Promises
Use SuiteScript to send asynchronous HTTP requests with promises for efficient error handling and response processing.
- Setting Sublist Field Values in SuiteScript
Set values for sublist fields in SuiteScript using the setSublistValue method. Understand required parameters and error handling.
- In This Help Topic
Explore N/log module guidelines, log levels, and script execution logs for efficient logging in SuiteScript.
Advertising
Reach Platform Professionals
Put your product in front of NetSuite experts who work with Platform every day.
Sponsor This Category