MSBA-342 · Lesson 8 of 12 · 20 min
Electronic reporting for developers
▶ Video coming soon A video version of this lesson is on the way.
Midway through the series, Thandeka Morrow arrived at the clinic with a printed letter. It came from the fictional motor supplier Ashgrove Motor Works, which supplied the electric motors on Cobalt Ridge's larger pumps. Ashgrove would reimburse Cobalt Ridge for motor failures under warranty, but only if claims arrived as an XML file in Ashgrove's own format, once a month, with a specific structure of claim, serial number, motor number, failure code and labor hours. Under the old system, someone typed the claims into Ashgrove's portal. Thandeka wanted the file produced by the system, from the warranty claims Prudence's service would create. Prudence assumed it was a job for X++ and an SSRS report. Desmond said it was a job for Electronic reporting, and that most of it would not be his job or hers.
This clinic explained what Electronic reporting, usually shortened to ER, is; why Microsoft built it for business users rather than developers; and the specific places where developers still matter: exposing data that ER cannot reach on its own, calling ER formats from application code, shipping configurations with a package, and keeping derived configurations healthy as Microsoft releases new versions.
What Electronic reporting is
ER is a tool for configuring formats for incoming and outgoing electronic documents according to the legal and business requirements of different countries and partners. Microsoft describes it as targeted at business users instead of developers: formats are built in visual designers, and a business user can configure a solution without a developer. ER replaced more than twenty different engines that earlier versions used for electronic documents, and it now underpins most of Microsoft's own regulatory reports, payment files, tax returns and electronic invoices.
ER separates three concerns. The data model describes the business domain in business terms: a warranty claim has a number, a date, a pump, a motor, a failure and lines of labor and parts. The model mapping connects that model to application data sources, such as tables, data entities, classes and calculated fields, or, for incoming documents, to updatable destinations. The format describes the structure of the electronic document and binds its elements to the data model. Because the format only knows the model, and only the mapping knows the database, an application upgrade that changes tables affects only the mapping, and a partner that changes its file layout affects only the format.
Configurations, providers and versions
Each ER component lives in a configuration, a wrapper that holds versions of that component. A configuration has an owner, the configuration provider. Configurations that Microsoft releases are owned by the Microsoft provider. A company that creates its own configurations registers itself as a provider and marks that provider as active; only configurations owned by the active provider can be edited, and only their draft versions. A version is completed when it is ready, and completed versions are what run in production. This model is what allows a partner or a customer to build on Microsoft's configurations without changing them.
Configurations are stored in repositories. Microsoft Learn lists the repository types as the file system, Operations resources, and Dataverse, and describes Dataverse as the central source for configurations. Microsoft's own configurations are published in the Global repository, where the discontinuation details show configurations that are no longer maintained. At Cobalt Ridge, Annelise registered the provider Cobalt Ridge Manufacturing, made it active in the CONFIG sandbox, and created a Dataverse-backed repository for the company's own configurations.
| Component | Who usually builds it | Cobalt Ridge example |
|---|---|---|
| Data model | Functional consultant or ER specialist | CR Warranty claim model |
| Model mapping | ER specialist, with a developer when data is hard to reach | Mapping to warranty and claim tables |
| Format | Functional consultant or ER specialist | Ashgrove claim XML; claim summary for Excel |
| X++ data source class | Developer | CRWarrantyClaimERHelper for labor hour rules |
| Format run from code | Developer | Monthly batch job producing the Ashgrove file |
Supported formats
ER formats can produce text, XML, JSON, PDF, Microsoft Word, Microsoft Excel and OpenXML worksheet output, according to Microsoft Learn. Text and XML formats are built element by element in the format designer. Excel and Word formats use a template document uploaded to the configuration, with named cells or content controls bound to format elements. ER can also parse incoming documents, such as bank statements in XML or text, and write their contents to application tables through a mapping. For Ashgrove, the format was XML; for Thandeka's own monthly review, a second format bound to the same model produced an Excel summary of the claims sent, so that the file and the review always agreed.
Where developers come in
Most of the Ashgrove solution was built by Annelise in the ER designers. Desmond's and Prudence's work fell into four places, and each is a recognizable developer task in ER projects.
The first is exposing data. ER model mappings can read tables, data entities and calculated fields directly, and can call X++ classes and methods. When a value needs logic that is awkward to express in ER's formula language, a developer writes a class with static methods that the mapping calls. Ashgrove wanted labor hours rounded to the quarter hour by a rule that depended on the failure code, with a cap that varied by motor size. Annelise could have written that in ER formulas, but it already existed in X++ in the claim calculator, so Prudence added a small helper class whose public static method returned the rounded hours for a claim line. The mapping called it as a class data source. One rule, one place.
/// Helper used by the CR Warranty claim model mapping (class data source).
public final class CRWarrantyClaimERHelper
{
/// Labour hours for a claim line, rounded and capped by Ashgrove's rules.
public static real reimbursableHours(RefRecId _claimLineRecId)
{
CRWarrantyClaimLine line = CRWarrantyClaimLine::findRecId(_claimLineRecId);
return CRWarrantyClaimCalculator::ashgroveHours(line);
}
/// Motor serial for a pump serial, from the bill of materials traceability.
public static str motorSerial(str _pumpSerial)
{
return CRPumpWarrantyService::componentSerial(_pumpSerial, 'MOTOR');
}
}The second is running a format from code. Many ER formats are started by the application, not by a person in the ER workspace: payment files run when a payment journal is generated, for example. The parameters table of the feature stores which format mapping to use, in a field based on the ER format mapping ID type, and the X++ code that generates the document uses the ER framework's API to run that format with the right parameters. For Ashgrove, Desmond added a warranty parameters field for the format mapping and a SysOperation batch job, scheduled for the second working day of each month, that ran the format for the previous month's approved claims and sent the file to the ER destination.
// Inside the controller/service of the monthly Ashgrove export batch job.
// API names are from the ER framework as commonly used; confirm in the reference metadata.
ERFormatMappingId formatMappingId = CRWarrantyParameters::find().CRAshgroveClaimFormatMapping;
ERObjectsFactory::createFormatMappingRunByFormatMappingId(
formatMappingId, "@CRCustom:AshgroveClaimFileName", true)
.withParameter(new ERModelDefinitionInputParametersAction()
.add('Model/Period/FromDate', fromDate)
.add('Model/Period/ToDate', toDate))
.run();The third is destinations and delivery. ER destinations decide where a format's output goes: a file download, an archive, an email, a printer, or a converted PDF. They are configured by administrators, but developers may need to write the small piece that sends a file onward to a system that ER does not reach natively, for example a partner's secure file transfer endpoint, usually through middleware. Ashgrove accepted email with an attachment, so a standard destination did the job.
The fourth is shipping and maintaining configurations. ER configurations are not X++ and are not compiled into packages in the usual way. They are moved between environments through repositories: exported and imported as XML files, shared through Dataverse, or shipped inside a model as resources and loaded through the Operations resources repository. Desmond preferred Dataverse for Cobalt Ridge's own configurations, so that the same completed version could be imported to UAT and production, and kept an exported copy of each completed version in Azure Repos alongside the code that called it, so that the code and the configuration could be reviewed together.
Deriving from Microsoft's configurations
When a Cobalt Ridge format needed to change a Microsoft format, for example to add a field to a payment file, the rule was never to edit Microsoft's configuration. Instead, Annelise would derive a configuration: create a child of Microsoft's version, owned by the Cobalt Ridge provider, containing only the changes. When Microsoft releases a new version of the base, ER can rebase the derived version, adopting Microsoft's changes automatically and showing any conflicts for manual resolution. This is the ER counterpart of the extension model in the second clinic series: build on the standard, never change it, and plan for updates.
Microsoft's localizations follow the same idea. The Mexican legal entity, CRMX, would start trading in January 2027, and Mexico requires electronic invoicing. Microsoft's localization for Mexico delivers those documents through ER-based configurations and related services, so the work for CRMX would mostly be importing and configuring Microsoft's configurations rather than building new ones. Desmond put a line in the register to check the current Mexican electronic invoicing documentation with the partner's localization team before the CRMX go-live plan was approved.
ER or SSRS?
Prudence had learned to build SSRS reports with a report data provider in the extension course, for the weekly casting report. When should a developer reach for SSRS and when for ER? Desmond's answer was practical. SSRS is for printed business documents and internal reports with complex layouts, built and changed by developers, and deployed with code. ER is for electronic documents exchanged with outside parties, especially where the format belongs to someone else and may change, where business users should own the format, and where versions and country variants matter. Many standard business documents can also be produced through ER-based business document management, which lets business users edit Word and Excel templates, and that option was on the list for Cobalt Ridge's customer-facing documents in a later release.
Testing an ER format
Testing an ER solution follows the same principles as testing code, with different tools. The ER designers let a user run a format against real data in a sandbox and inspect the output, and the model mapping designer can show the values each data source returns for a sample record. Annelise and Prudence agreed on a test set of eighteen claims chosen to cover every rule in Ashgrove's specification: claims with and without parts, claims at the labor hour cap, claims for each motor size, a claim in each legal entity, and one claim that had been rejected and should be excluded. For each, they wrote down the expected XML by hand, then compared the format's output line by line.
Two problems came out of the comparison. Ashgrove's specification required dates in a day-month-year layout with dashes, while the format produced the ISO layout; Annelise fixed it with a formatting function in the format. And one claim in CRUS appeared in the CRCA file, because the mapping read claims across companies; a filter on the legal entity in the mapping fixed it. Neither problem needed a developer. Desmond pointed out that this is exactly the benefit of ER: the people closest to the requirement can find and fix most of the problems without a code release.
Traceability and performance
ER keeps a record of each format run, and files produced through destinations can be archived, so that months later Thandeka could show which claims were in which file. Desmond asked for the archive to be turned on for the Ashgrove destination and for the batch job to log the number of claims and the total reimbursable amount, so that the monthly figure could be checked against the supplier's remittance without opening the XML.
Performance mattered less for Ashgrove, whose file held a few dozen claims a month, but Desmond warned that ER formats over large data sets can be slow when the mapping reads related records one at a time. ER provides a performance trace that shows how long each data source took and how often it was called, and the usual fixes are to add caching to frequently read data sources, to filter early in the mapping rather than late in the format, and to move heavy logic into an X++ helper that can use a set-based query. Microsoft's own large formats, such as tax returns, use these techniques, and they are worth knowing before a customer's own format grows.
Worked problem
Splitting an ER project
Ashgrove announces that from April 2027 it will need a new element for the firmware version of each motor and will rename the failure code element. Which parts of the solution change, and who changes them?
Show solution
- The firmware version must come from somewhere. If it is stored on the pump's component record, the model gains a field and the mapping binds it; if it needs logic, Prudence adds a method to the helper class.
- Renaming the element changes only the format: Annelise edits a draft of the Ashgrove format, renames the element, and completes a new version.
- The batch job and its X++ code do not change, because they run whatever format mapping the parameter names.
- The new format version is tested in UAT and imported to production before April, with the old version kept for any reruns of earlier months.
Answer: Format change by the ER specialist, model and mapping change for the new field, possibly a helper method by the developer, and no change to the batch job.
Common mistakes
MistakeWriting an X++ class that builds a partner XML file by hand.
InsteadUse an ER format, so that the format can change without a code release.
MistakeEditing a Microsoft configuration directly.
InsteadDerive a configuration owned by your own provider and rebase it when Microsoft updates the base.
MistakeDuplicating a business rule in ER formulas when it already exists in X++.
InsteadExpose the X++ logic through a helper class used as a data source.
MistakeForgetting that ER configurations move separately from code packages.
InsteadPlan configuration import through Dataverse or files alongside each code deployment.
Summary and key terms
- Electronic reporting configures incoming and outgoing electronic documents and is designed for business users.
- ER separates the data model, the model mapping to application data, and formats bound to the model.
- Configurations are owned by providers, versioned, and stored in repositories such as Dataverse.
- Developers expose data through X++ helper classes, run formats from code, help with delivery, and manage configuration movement.
- Changes to Microsoft configurations are made in derived configurations that can be rebased.
- Electronic reporting (ER)
- A configurable tool for producing and parsing electronic documents without code.
- ER data model
- A business-domain description of the data in an electronic document.
- Model mapping
- The binding between an ER data model and application data sources or destinations.
- ER format
- The structure of an electronic document bound to a data model.
- Configuration provider
- The owner of ER configurations; only the active provider can edit its drafts.
- Derived configuration
- A child configuration that changes a base configuration and can be rebased on new versions.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Why does an application upgrade that changes tables usually not require a change to an ER format?
Show answer
Formats are bound to the data model; only the model mapping refers to tables.
What did Prudence build for the Ashgrove solution, and why?
Show answer
A helper class with static methods used as a class data source, so that the labor hour rule stayed in one place in X++.
Which output formats does ER support according to Microsoft Learn?
Show answer
Text, XML, JSON, PDF, Word, Excel and OpenXML worksheet.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.