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)

IdCustomerCity
1Aarav SystemsPune
2Émile TradersLyon
// 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

← QA Smart Reports start page