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.

·3 min read·View Oracle Docs

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 NameTypeReturn TypeSupported Script TypesDescription
autoJoin(options)Methodquery.ComponentClient and server scriptsCreates a join relationship automatically based on record types.
createColumn(options)Methodquery.ColumnClient and server scriptsGenerates a query result column based on the component.
createCondition(options)Methodquery.ConditionClient and server scriptsDefines a filtering condition based on the component.
createSort(options)Methodquery.SortClient and server scriptsEstablishes a sort order based on the component.
join(options)Methodquery.ComponentClient and server scriptsAn alias for autoJoin, creates a join relationship.
joinFrom(options)Methodquery.ComponentClient and server scriptsCreates an explicit directional join from another component.
joinTo(options)Methodquery.ComponentClient and server scriptsCreates an explicit directional join to another component.
childPropertyObjectClient and server scriptsHolds child components as key-value pairs.
parentPropertyStringClient and server scriptsRepresents the parent component.
sourcePropertyStringClient and server scriptsStates the source query type of the component, set during a directional join.
targetPropertyStringClient and server scriptsRepresents the target query type, set during a join.
typePropertyStringClient and server scriptsIndicates the query type of the component.

How to Use These Members?

  1. Creating Initial Query: Start with the root component using query.create(options), defining your initial query type.
  2. Building Joins: Use Query.autoJoin(options) for the initial join, then utilize Component.autoJoin(options) or Component.join(options) for subsequent joins.
  3. Adding Columns and Conditions: You can dynamically create columns and conditions with createColumn and createCondition, expanding your query's capabilities.
  4. Sorting Results: Implement createSort to 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?
No, there is no mention of needing to enable a feature flag to use Component Object Members in SuiteScript. They are part of the SuiteScript API available for client and server scripts.
Can I use Component Object Members with existing database queries in NetSuite?
Yes, Component Object Members are designed to enhance existing database queries in NetSuite by allowing the creation of complex joins, conditions, and sorting within SuiteScript.
Are there governance limits associated with using Component Object Members for queries?
There are no specific governance limits mentioned for using these methods in constructing queries with Component Object Members.
What script types support the use of Component Object Members for queries?
Component Object Members are supported in both client and server scripts, allowing for dynamic query construction in different NetSuite environments.
Source: Component 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 →