TemplateRenderer.addQuery(options)
Method Description |
Adds a SuiteAnalytics Workbook query to use as the renderer’s data source. You can specify the query in two ways:
One of This method returns a maximum of 5000 results in the query result set. If a query matches more than 5000 results, you must use There is no governance for this method. When the renderer is executed, rendering consumes 10 units for every iteration through the results. If the query is specified using a workbook ID, rendering consumes an additional 5 units before the first iteration through the results. |
Returns |
void |
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Parent Object |
|
Sibling Object Mambers |
|
Since |
2019.2 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
string |
required if |
Workbook query ID. |
|
number |
optional |
Page index. |
|
number |
optional |
Page size. The minimum value is 5, and the maximum value is 1000. |
|
string |
required |
Name of the results iterator variable referred to in the template. |
|
query.Query object |
required if |
Workbook query definition. |
Errors
Error Code |
Error Message |
Thrown If |
---|---|---|
MUTUALLY_EXCLUSIVE_ARGUMENTS |
Cannot use mutually exclusive arguments. |
Both query and ID parameters are provided. |
NEITHER_ARGUMENT_DEFINED |
One of the following arguments is mandatory: id, query. |
Neither options.id nor options.query are provided. |
SSS_MISSING_REQD_ARGUMENT |
TemplateRenderer.addQuery: Missing a required argument: options.templateName. |
The template name is not specified. |
UNABLE_TO_LOAD_QUERY |
Unable to load query: invalidId. |
The query parameter is provided but the ID is not valid. |
WRONG_PARAMETER_TYPE |
Wrong parameter type: options.query is expected as query.Query. |
The query parameter is provided, but the ID has the incorrect type. |
Syntax
Note that TemplateRenderer.addQuery(options) binds the results iterator to a template variable. This iterator provides sequential access to the query results. For random access to search results in FreeMarker, process your search data before rendering, and then pass the processed data to the template using TemplateRenderer.addCustomDataSource(options).
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/render Module Script Samples.
//Add additional code
...
var search = query.create({
type: query.Type.TRANSACTION
});
var transactionlines = search.join({
fieldId: "transactionlines"
});
search.condition = transactionlines.createCondition({
fieldId: "netamount",
operator: query.Operator.GREATER,
values: 1
});
search.columns = [
transactionlines.createColumn({
fieldId: "netamount",
label: "Amount"
}),
];
// get instance of TemplateRenderer - https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4412065265.html
var renderer = render.create();
renderer.templateContent = "<#list page as line><item>${line['0@label']}:${line[0]}</item>\n</#list>"
renderer.addQuery({
templateName: "page",
query: search,
pageSize: 3, // minimum page size is 5, so result will contain 5 lines instead of 3
pageIndex: 0,
})
...
// Add additional code