Why do you need this change?
We are implementing a pre-posting FatturaPA preview for Sales Invoices / Credit Memos in Business Central Cloud.
The goal is to let a user review the exact FatturaPA XML, and render it with the official Agenzia delle Entrate XSLT, before posting the document.
Describe the request
Please expose a cloud-safe API boundary in codeunit 12179 "Export FatturaPA Document" that allows an extension to generate the standard Microsoft FatturaPA XML from already prepared temporary "Fattura Header" and "Fattura Line" buffers.
The existing procedure is very close to what is needed:
[Scope('OnPrem')]
procedure GenerateXMLFile(
var TempBlob: Codeunit "Temp Blob";
var TempFatturaLine: Record "Fattura Line" temporary;
TempFatturaHeader: Record "Fattura Header" temporary;
ClientFileName: Text[250])
For a SaaS/Cloud extension this procedure cannot be used because it is scoped OnPrem.
Business scenario
We are implementing a pre-posting FatturaPA preview for Sales Invoices / Credit Memos in Business Central Cloud.
The goal is to let a user review the exact FatturaPA XML, and render it with the official Agenzia delle Entrate XSLT, before posting the document.
It is important that the preview uses Microsoft's standard FatturaPA serializer rather than a duplicated custom XML writer, so that:
- XML element ordering and formatting remain identical to the standard exporter;
- future Business Central updates to the FatturaPA implementation are inherited automatically;
- existing integration events such as
OnBeforePopulatePaymentData, OnBeforePopulateOrderData, OnTryCreateFatturaElettronicaBodyOnAfterTempFatturaLineSetFiltersForDocument, and OnAfterCreateBlobXML continue to behave consistently;
- extensions do not have to clone codeunit 12179 simply to obtain an XML stream.
Why running codeunit 12179 directly is not suitable for preview
Running Export FatturaPA Document through its normal OnRun path is not a good substitute because it first calls Fattura Doc. Helper.CollectDocumentInformation on a posted source document.
For a pre-posting preview:
- the source is an unposted
Sales Header / Sales Line;
- VAT summaries and payment instalments need to be prepared from the current unposted document state rather than posted
VAT Entry / Cust. Ledger Entry records;
Fattura Doc. Helper currently obtains a new FatturaPA progressive number through GetNextProgressiveNo(), so invoking the full standard collection path for every preview can consume real progressive numbers.
The extension can prepare suitable temporary Fattura Header / Fattura Line buffers itself while reusing the existing helper and its events where possible.
What is missing is a supported cloud API that hands those buffers to the same Microsoft XML generation logic used by the posted export.
Requested solution
Preferred option: make GenerateXMLFile available to cloud extensions by removing [Scope('OnPrem')], provided there are no technical reasons preventing that.
Alternatively, please add a new public cloud-safe procedure with equivalent semantics, for example:
procedure GenerateXMLFromBuffers(
var TempBlob: Codeunit "Temp Blob";
var TempFatturaLine: Record "Fattura Line" temporary;
TempFatturaHeader: Record "Fattura Header" temporary;
ClientFileName: Text[250])
The important requirement is that this procedure invokes the existing Microsoft FatturaPA serializer rather than exposing or requiring a second implementation.
Benefits beyond preview
A reusable buffer-to-XML API would also support:
- pre-posting validation tools;
- test automation comparing expected FatturaPA output;
- controlled previews for custom sales document workflows;
- extensions that add additional structured FatturaPA data while remaining aligned with Microsoft's current schema implementation.
Target
Business Central Cloud / SaaS, current Italian localization (BC 28.x).
Internal work item: AB#646218
Why do you need this change?
We are implementing a pre-posting FatturaPA preview for Sales Invoices / Credit Memos in Business Central Cloud.
The goal is to let a user review the exact FatturaPA XML, and render it with the official Agenzia delle Entrate XSLT, before posting the document.
Describe the request
Please expose a cloud-safe API boundary in codeunit 12179 "Export FatturaPA Document" that allows an extension to generate the standard Microsoft FatturaPA XML from already prepared temporary "Fattura Header" and "Fattura Line" buffers.
The existing procedure is very close to what is needed:
For a SaaS/Cloud extension this procedure cannot be used because it is scoped
OnPrem.Business scenario
We are implementing a pre-posting FatturaPA preview for Sales Invoices / Credit Memos in Business Central Cloud.
The goal is to let a user review the exact FatturaPA XML, and render it with the official Agenzia delle Entrate XSLT, before posting the document.
It is important that the preview uses Microsoft's standard FatturaPA serializer rather than a duplicated custom XML writer, so that:
OnBeforePopulatePaymentData,OnBeforePopulateOrderData,OnTryCreateFatturaElettronicaBodyOnAfterTempFatturaLineSetFiltersForDocument, andOnAfterCreateBlobXMLcontinue to behave consistently;Why running codeunit 12179 directly is not suitable for preview
Running
Export FatturaPA Documentthrough its normalOnRunpath is not a good substitute because it first callsFattura Doc. Helper.CollectDocumentInformationon a posted source document.For a pre-posting preview:
Sales Header/Sales Line;VAT Entry/Cust. Ledger Entryrecords;Fattura Doc. Helpercurrently obtains a new FatturaPA progressive number throughGetNextProgressiveNo(), so invoking the full standard collection path for every preview can consume real progressive numbers.The extension can prepare suitable temporary
Fattura Header/Fattura Linebuffers itself while reusing the existing helper and its events where possible.What is missing is a supported cloud API that hands those buffers to the same Microsoft XML generation logic used by the posted export.
Requested solution
Preferred option: make
GenerateXMLFileavailable to cloud extensions by removing[Scope('OnPrem')], provided there are no technical reasons preventing that.Alternatively, please add a new public cloud-safe procedure with equivalent semantics, for example:
The important requirement is that this procedure invokes the existing Microsoft FatturaPA serializer rather than exposing or requiring a second implementation.
Benefits beyond preview
A reusable buffer-to-XML API would also support:
Target
Business Central Cloud / SaaS, current Italian localization (BC 28.x).
Internal work item: AB#646218