Calling reports from your own pages
This page plays the part of a page in your application. It loads one script and calls
showReport(reportName, parameters, options). The report goes straight to the browser's print preview;
parameters you do not pass are asked for in a small dialog. Sign in as a user with the viewer role when asked.
1. Include the library
<!-- after your own scripts (and after qa-utility.js if you still use it) --> <script src="/qa-smart-reports/viewer/assets/js/qa-report-viewer.js"></script>
2. Try it
Report without parameters
showReport("samples/orders-by-month.qsr");
Parameters from your page
showReport("samples/sales-by-customer", {
FromDate: from.value, // "YYYY-MM-DD"
ToDate: to.value,
Statuses: ["paid", "shipped"] // multi-value: array
});
Let the user choose (always ask)
showReport("samples/customer-list", { Country: "India" }, { prompt: "always" });
PDF file instead of printing
showReport("samples/customer-list", { Country: "Japan" }, { format: "pdf" });
"Print this record" buttons in a grid (old qa-utility.js style still works)
| Id | Customer | City | |
|---|---|---|---|
| 1 | Aarav Systems | Pune | |
| 2 | Émile Traders | Lyon |
// new form: pass the record filter as criteria
showReport("samples/customer-list", {}, { criteria: [{ table: "customers", field: "id", value: 2 }], prompt: "never" });
// old form, unchanged: showReport(button, reportName, criteria)
showReport(this, "reports/customer-list.qbr", { table: "customers", field: "id", value: 2 });
// map old names to new locations once: QAReport.nameMap["customer-list"] = "samples/customer-list";
3. Results
showReport(name, params, options)
.then(function (r) { /* r.status: "printed" | "downloaded" | "cancelled"; r.pages */ })
.catch(function (e) { /* e.message: e.g. not on the same site */ });
Events appear here.
4. Notes
- Report name = location below the server's reports folder, with or without
.qsr:"billing/2026/invoice.qsr". Absolute paths and..are refused. - Same site: install QA Smart Reports under the same scheme, host and port as your application (for example
https://erp.example.com/qa-reporting/). - Sign-in: users sign in once (the dialog appears automatically). To reuse your application's login instead, use
auth.mode = 'external'— see docs/EMBEDDING.md. - Values are checked on the server against the report's parameter types; nothing is evaluated in the browser.