query.load(options)
Method Description |
Loads an existing query as a query.Query object. Use this method to load a query definition that was previously created using the SuiteAnalytics Workbook UI. After the query is loaded, you can modify the query definition (for example, by setting additional property values), join the query definition with other query types, and perform the query in the same way as queries that you create using query.create(options). You can provide either the workbook ID or the dataset ID of the query definition to load. You can obtain these IDs in the SuiteAnalytics Workbook UI. For more information, see Navigating SuiteAnalytics Workbook. This method loads only the table view in the specified workbook. However, a workbook can include no table views, or it can include multiple table views. This method throws an exception in each of these cases (see Errors). If a workbook includes multiple table views, you can use query.listTables(options) to determine the ID of a specific table view. You can use this ID to load the corresponding table view.
Important:
The N/query module lets you create and run queries using the SuiteAnalytics Workbook query process. You can use the N/query module to load and delete existing queries, but you cannot save queries. You can save queries using the SuiteAnalytics Workbook interface. For more information, see Navigating SuiteAnalytics Workbook. |
Returns |
|
Supported Script Types |
Client and server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
5 units |
Module |
|
Sibling Module Members |
|
Since |
2018.2 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
string |
required |
The workbook ID or dataset ID of the query definition to load. You can obtain these IDs in the SuiteAnalytics Workbook UI. For more information, see Navigating SuiteAnalytics Workbook. |
Errors
Error Code |
Thrown If |
---|---|
|
A query with the specified ID cannot be loaded because the query does not exist or you do not have permission to load it. |
|
More than one table view is included in the specified workbook or dataset. |
|
No table views are included in the specified workbook or dataset. |
If the loaded query does not return a desired sorting order, you must use the Query.runPaged() method for default sorting or specify your custom sorting before script .
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 myLoadedQuery = query.load({
id: 'custworkbook237'
});
var mySalesRepJoin = myLoadedQuery.autoJoin({
fieldId: 'salesrep'
});
var results = myLoadedQuery.run();
...
// Add additional code