Query.join(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Creates a join relationship.

Important:

This method is an alias to Query.autoJoin(options). Use Query.autoJoin(options) instead of this method to create simple joins. Use Query.joinFrom(options) and Query.joinTo(options) to create explicit directional joins.

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 Query.join(options) to create your first join (query.Component). Then use Component.autoJoin(options) to create each subsequent join (query.Component).

Note:

This method is a shortcut for the chained Query.root and Component.join(options): Query.root.join(options). The Query.root property references the root component, which is a query.Component object.

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

query.Component

Supported Script Types

Client and server scripts

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

Governance

None

Module

N/query Module

Parent Object

query.Query

Sibling Object Members

Query Object Members

Since

2018.1

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.fieldId

string

required

The column type (field type) that joins the parent component to the new component. This value determines the columns on which the components are joined and the type of the newly joined 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.

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.join({ 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

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

General Notices