Query.joinTo(options)
Method Description |
Creates an explicit directional join relationship from a parent component to its child component (a forward join). This method sets the Component.target property on the returned query.Component object. Use the method query.create(options) to create your initial query definition (query.Query). The initial query definition uses one query type. For available query types, see query.Type. After you create the initial query definition, use this method to create your first join as an explicit directional join to another component from this component.
Note:
This method is a shortcut for the chained Query.root and Component.joinTo(options):
Important:
The N/query module supports the same record types that are supported by the SuiteAnalytics Workbook interface. For more information, see Available Record Types. |
Returns |
|
Supported Script Types |
Client and server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Parent Object |
|
Sibling Object Members |
|
Since |
2018.2 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
string |
required |
The column type (field type) that joins the parent component to the new component. Obtain this value from the Records Catalog. The Records Catalog lists every record type and field that is available using SuiteAnalytics Workbook and the N/query module. For more information, see Records Catalog Overview. |
|
string |
required |
The query type of the component joined to this component. This value sets the Component.target property. This value can be described as the relationship of this component, and it determines the target query type of the newly joined component. |
Errors
Error Code |
Thrown If |
---|---|
|
The specified join relationship already exists. |
Syntax
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 myEmployeeJoin = myTransactionQuery.joinTo({
fieldId: 'createdby',
target: 'employee'
});
myTransactionQuery.columns = [
myTransactionQuery.createColumn({
fieldId: 'entity'
}),
myEmployeeJoin.createColumn({
fieldId: 'entityid'
}),
myEmployeeJoin.createColumn({
fieldId: 'email'
})
];
...
// Add additional code