Modules

filter

 

Objects/Functions

module (N/query)

SuiteScript 2.0

query.Query

// Please search https://system.netsuite.com/app/help/helpcenter.nl?search=query.Query for more information.

N/query Module
query.Query
Object Description: The query.Query object encapsulates the query definition. To create a query with the N/query module: Use the query.create(options) method to create your query definition (this object). The initial query definition uses one query type. For available query types, see query.Type. After you create the initial query definition, use Query.autoJoin(options) to create your first join. Then use either Query.autoJoin(options) or Component.autoJoin(options) to create subsequent joins. The query definition always contains at least one query.Component object. The query.Component object encapsulates one component of the query definition. Each new component is created as a child to the previous component, and all components exist as children to the query definition. You can think of a component as a building block; each new component builds on the previous component created. The last component created encapsulates the relationship between it and all of its parent components. Queries with joins contain multiple components. The query definition contains a child query.Component object for each of the following: The initial query definition: The initial query.Component object is called the root component. It encapsulates the initial query type passed to query.create(options). The root component is automatically created with the initial query definition and is a child to the query.Query object. The Query.root property contains a reference to the root component. The first join: The second query.Component object is created with Query.autoJoin(options). It encapsulates the relationship between the initial query definition and the second query type. This relationship is determined by the field ID passed to Query.autoJoin(options). The second query.Component object is a child to the root component. Each subsequent join: The third query.Component object is created with Query.autoJoin(options) or Component.autoJoin(options). All subsequent joins are also created with Query.autoJoin(options) or Component.autoJoin(options). Each of these query.Component objects encapsulates the relationship between all previous query types and the new query type. This relationship is determined by the field ID passed to Component.autoJoin(options).
Supported Script Types: Client and server scripts For more information, see SuiteScript 2.0 Script Types.
Module: N/query Module
Methods and Properties: Query Object Members
Since: 2018.1
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=query.Query

Example:

// Code Example 1
// Add additional code
//...
var myTransactionQuery = query.create({
type: query.Type.TRANSACTION
});

var myEntityJoin = myTransactionQuery.autoJoin({
fieldId: 'entity'
});

myTransactionQuery.columns = [
myEntityJoin.createColumn({
fieldId: 'subsidiary'
})];

myTransactionQuery.sort = [
myTransactionQuery.createSort({
column: myTransactionQuery.columns[0],
ascending: false
})
];

var results = myTransactionQuery.runPaged({
pageSize: 10
});
//...
// Add additional code

//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_1510275177.html