Query.run()
The content in this help topic pertains to SuiteScript 2.0.
Method Description |
Executes the query and returns the query result set. This method returns a maximum of 5000 results in the query result set. If a query matches more than 5000 results, you must use Query.runPaged() or Query.runPaged.promise() to retrieve the full set of results. |
Returns |
|
Supported Script Types |
Client and server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
10 units |
Module |
|
Parent Object |
|
Sibling Object Members |
|
Since |
2018.1 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
string |
optional |
A unique identifier used for potential performance issues in a query. If your query produces performance issues, the custom script ID identifies where the update will need to occur. This ID can also be used as a precaution to speed up performance fixes, if necessary.
Note:
The Script ID must be unique or the performance enhancements will affect each query with the same customScriptID. |
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 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({ customScriptId: 'myCustomScriptId' });
...
// Add additional code