DoReport (reportName, format, title, parameters...)

Result Type:  a path string

Definition:  Generates a report, either returning the text of the report, or a path to the generated output file.

Format can be "pdf", "html", "text" or "". For the first 3, the return value is the path to a temporary file that will be deleted when you quit. For a an empty or unknown format string, the function will return the actual tab-delimited report output instead of a path.

Parameters should be strings in the form "paramName=paramValue". Parameters are inserted into the name table and are available to the report. An associative array is also acceptable—each element of the array will be inserted into the name table with its key as the variable name.

To specify the period range for a financial report you must supply parameters named from and to which may be dates (as yyyymmdd) or period numbers (dates will be mapped to periods). The report will run for each period in the range. If no period range is specified, the current date will be assumed.


doreport("Balance Sheet", "preview", "Balance Sheet", "from=20160331", "to=20160331", "include_unposted=1") // to preview
let t = doreport("Balance Sheet", "", "Balance Sheet", "from=20160331", "to=20160331") // to tab-delim text string
let h = doreport("Balance Sheet", "html", "Balance Sheet", "from=20160331", "to=20160331") // to html file

By default, any custom control variables will take on the values last saved in the report document. You can pass values for custom controls defined in the report, but to have your passed values override those last stored in the report document, you must include an additional parameter "override_doc_custom=1".

Example:  In this case, the_name_code is the name of a custom control, so we must pass "override_doc_custom=1" as well in order to override the value stored in the report.

let pdfPath = DoReport("Statement.crep", "pdf", "Statement", "the_name_code=" + n.code, "override_doc_custom=1")

Availability:  MWScript handlers. Thus function is closely analogous to the command line and REST doreport commands. A similar DoReport command is also available to Applescript/COM.