Example Report
All needed classes are in the space of names PTLRuntime.NETScript.Report. To get a report, at first we need to request the appropriate instance of the class Report using static methods, for example:
Report.GetReportByName(name);
It is possible to get a report by name, by identifier, and also the full list of reports allowed to the user.
Next, if a report has some parameters, then it is necessary to fill their specific values. Number and types of the parameters are unique for each report; the user sees them when requesting a report using Report panel. We don’t need to refer to the collection ReportParameters. The example how to fill in the parameters of is below:
Dictionary<string, ReportParameter> parameters = report.ReportParameters; //setting the current accoount and time range AccountsReportParameter accountParameter = parameters["login"] as AccountsReportParameter; if (accountParameter != null) accountParameter.Value = new List<Account>() { Accounts.Current }; DateTimeReportParameter fromDateParameter = parameters["fromDate"] as DateTimeReportParameter; if (fromDateParameter != null) fromDateParameter.Value = FromDate; DateTimeReportParameter toDateParameter = parameters["toDate"] as DateTimeReportParameter; if (toDateParameter != null) toDateParameter.Value = ToDate;
After setting the parameters, we can get data of the report by evoking the function RecieveData. It will request the report and present it in the form of DataTable. Usually one table corresponds to the one report, but the number of the tables can be greater for the compound reports. The structure of the table repeats the structure of the report – it has the named columns and rows with data.