query.Query

Note:

The content in this help topic pertains to SuiteScript 2.0.

Object Description

The query.Query object encapsulates the query definition. To create a query with the N/query module:

  1. 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.

  2. After you create the initial query definition, use Query.autoJoin(options) to create your first join.

  3. 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:

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Module

N/query Module

Methods and Properties

Query Object Members

Since

2018.1

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/query Module Script Samples.

            // 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 

          

Related Topics

N/query Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices