Modules

filter

 

Objects/Functions

module (N/query)

SuiteScript 2.0

query.Component

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

N/query Module
query.Component
Object Description: One component of the query definition. Each new component is created as a child to the previous component. All components exist as children to the query definition (query.Query). 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. The query definition always contains at least one component. Queries with joins contain multiple components. The query definition (query.Query) 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 query.Query object and is a child of 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 join ID passed to Query.autoJoin(options) . The second query.Component object is a child of the root component. Each subsequent join: The third query.Component object is created with Component.autoJoin(options). All subsequent joins and their respective query.Component objects are also created with 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 join 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: Component Object Members
Since: 2018.1
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=query.Component

Example:

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

var mySalesRepJoin = myCustomerQuery.autoJoin({
fieldId: 'salesrep'
});

myCustomerQuery.columns = [
myCustomerQuery.createColumn({
fieldId: 'entityid'
}),
myCustomerQuery.createColumn({
fieldId: 'id'
}),
mySalesRepJoin.createColumn({
fieldId: 'entityid'
}),
mySalesRepJoin.createColumn({
fieldId: 'email'
}),
mySalesRepJoin.createColumn({
fieldId: 'hiredate'
}),
];

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

var resultSet = myCustomerQuery.run();
//...
// Add additional code

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