NSOA.report.data(reportId,optionalParameters)
Use this function to read published report data available to the user executing the script. The function returns a specialized report data iterator (length, index, next, each).
For more information, see Business Intelligence Connector. See also OData Explorer to browse available OData resources and get started with a sample code, and NSOA.listview.data(listviewId) to read published list view data.
The Business Intelligence Connector feature must be enabled for your account to use NSOA.listview and NSOA.report functions. The Business Intelligence Connector feature is a licensed add-on. To enable this feature, contact your OpenAir account manager.
For more information about publishing list views and reports to the OpenAir OData service, see Business Intelligence Connector.
Parameters
-
reportId
— the ID number of the report (integer). -
(optional)
optionalParameters
— an object with the following properties:-
(optional)
select
— the list of columns to return (string array). -
(optional)
filter
— a logical expression defining the criteria items must match to be included in the response (string).
For information about column names and
filter
expression syntax and guidelines, see OData Query Options. -
Returns
-
A specialized report data iterator (length, index, next, each).
-
length
— number of items -
index
— index of last returned item -
next
— returns next item from iterator or undefined when iterator is done -
each
— calls specified function for each item in the iterator
-
Units Limit
-
10 units for each 1000-item page loaded into iterator on-demand. Consumes 10 units for the first fetch even when the page is empty.
Since
-
October 13, 2018
Example
// get the iterator for report data; it has following members
// it consumes 10 units for each 1000-item page loaded into iterator on-demand
// * 'length' - number of items
// * 'index' - index of last returned item
// * 'next' - returns next item from iterator or undefined when iterator is done
// * 'each' - calls specified function for each item in the iterator
//
// optionalParameters:
// * 'select' - list of field names to be returned
// * 'filter' - limiting condition
var iterator = NSOA.report.data(
7,
{
select: ["Name", "Remaining Budget"],
filter: "Name eq 'Nathan Brown'"
}
);
// get number of records published
var row_count = iterator.length;
// grab first two records
var first = iterator.next();
var second = iterator.next();
// process rest of the report
iterator.each(function(record, index) {
// search for particular name
if (record.Name === "Nathan Brown") {
// set the field value
NSOA.form.setValue("remaining_budget__c", record["Remaining Budget"]);
// stop iterating
return false;
}
});