🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators opendocumentreportshow
This page was created by Lars.olofsson on 2019-03-22. Last edited by Wikiadmin on 2026-07-29.

You can use opendocumentreportshow in an OCL expression to merge a report template with data from a ViewModel and open the generated result in the browser.

Syntax

self.opendocumentreportshow(nameOfViewModel)

The argument identifies the ViewModel that provides both the report data and the information used to locate the template.

Part Meaning
self The root object for the reporting ViewModel.
opendocumentreportshow Generates the report in the same way as opendocumentreportasblob, then opens the resulting HTML in the browser.
nameOfViewModel The reporting ViewModel, supplied as its name or as a ViewModel expression.

Use a reporting ViewModel

Before calling this operator, create a ViewModel that extracts the values required by the template. The reporting ViewModel also supplies the template-location information. For template formats, template locations, tags, and report ViewModel requirements, see Documentation:OpenDocument.

For example, if a report template contains %CustomerName%, the reporting ViewModel must provide an attribute named CustomerName. The merge replaces the tag with the value supplied by that ViewModel.

Call the operator

  1. Identify the object that will be the root object of the reporting ViewModel.
  2. Create or select the reporting ViewModel that contains the report data and template information.
  3. Add an OCL expression that calls opendocumentreportshow on that root object.
  4. Run the action. The generated HTML opens in the browser.

Supply the ViewModel name as a string

Use the ViewModel name as a string when that is how your expression identifies the reporting ViewModel.

self.opendocumentreportshow('myviewmodelname')

Supply a ViewModel expression

You can also refer to the ViewModel through the class's ViewModels expression.

self.opendocumentreportshow(ReportRoot.ViewModels.ReportingViewmodel)

In this example, ReportRoot is the class that owns the reporting ViewModel, and ReportingViewmodel is the ViewModel used for the report. The object represented by self becomes that ViewModel's root object.

Choose the right report operation

Operation Use it when
opendocumentreportshow You want to generate the report and open the resulting HTML in the browser.
opendocumentreportasblob You need the generated report as an array of bytes for further handling.

See Documentation:OpenDocument for the OpenDocument report workflow. For HTML or XML templates, see Documentation:HtmlReport.

Template and tag considerations

  • OpenDocument templates can be retrieved from a BLOB attribute, a URL, or the local filesystem. HTML templates can also be used when the template file name ends in .htm or .html.
  • Template tags use the attribute name surrounded by percent signs. For example, an attribute named CustomerName is referenced as %CustomerName%.
  • Add %meta% to an OpenDocument template to generate the available tag list. The tag must be the first string in its element and is case-sensitive.
  • When editing an ODT template in Microsoft Word, invisible font formatting or line breaks inside a tag can prevent tag recognition. Copy the complete tag, including the percent signs, as plain text when needed.

Troubleshooting

Symptom Check
A tag remains unchanged in the output Confirm that the reporting ViewModel exposes an attribute with exactly the same name as the tag, including case, and that the tag has not been split or formatted by the document editor.
The intended template is not used Confirm that the reporting ViewModel supplies valid template-location information. Review the supported template locations in Documentation:OpenDocument.
You need a file value instead of a browser result Use opendocumentreportasblob rather than opendocumentreportshow.
An HTML template does not merge as expected Ensure that the template is well-formed HTML. See Documentation:HtmlReport.

See also