Skip to main content

Extensibility (developers)

The eInvoice Sender is built around a small set of AL interfaces so that partners and customers can extend it - add support for new document types, plug in a different reader, or add their own validation rules - without modifying the base app. This page is aimed at developers.

Interface 1 - DXP eInv Doc Exporter

Implement DXP eInv Doc Exporter to build the export payload for a given document type. It has a single method, CreateDocument(DocHeader: Variant): JsonObject - turning one kind of Business Central document into the JSON payload the pipeline serializes and sends to generation.

Implementations are bound through the extensible Export Document enum: add a value for your document type and point it at your implementing codeunit. The pipeline selects the exporter by resolving this enum, so registering a new exporter is a matter of extending it.

Interface 2 - DXP eInv Doc Reader V2

Implement DXP eInv Doc Reader V2 to provide a reader over the CIM (common information model) representation of a document - its ReadDocument method fills the CIM buffers (document, party, line, allowance/charge, payment, attachment) so rules and generation can consume the data uniformly.

The Export Document enum binds both interfaces: each enum value points at an exporter and a reader for that document type. When you add a new document type you provide both.

Interface 3 - DXP eInv IValidation Rule

Implement DXP eInv IValidation Rule to add validation rules. It has two methods: Evaluate (runs the check and appends findings) and GetMetadata (returns the rule's category, default severity, stage, description and fix hint - which is what seeds Rule Setup). A single codeunit can dispatch on the rule id and serve many rules, keeping within the object-ID budget.

Rules are bound through the extensible Validation Rule enum, which provides a dedicated CUSTOM extension point for customer- and partner-supplied rules. Add an enum value bound to your implementing codeunit, and the rule participates in validation like any built-in rule - it appears in Rule Setup where its Enabled flag, severity override and stage can be configured.

The OnCollectValidationRules event

The app publishes the OnCollectValidationRules integration event. Subscribe to it to register your rule implementations with the validation engine at runtime. This is the hook that lets an extending app contribute rules into the collection the pipeline and the live compliance check both use.

Two events for field assignments

A field assignment whose Source Type is Extension asks an extension for its value. The app publishes two integration events for this:

  • OnResolveAssignmentValue - (AssignmentCode: Code[20]; FieldPath: Text; SourceRecRef: RecordRef; var Value: Text; var IsHandled: Boolean). It is raised for each assignment whose source type is Extension; set Value and IsHandled. SourceRecRef is the posted header for a header field and the posted line for a line field, and the assignment code and the field path say which value is being asked for. Use this rather than OnBeforeSetJsonValue, which the payload serializer no longer raises.
  • OnLookupPostedDocument - (ExportDocType: Enum "DXP eInv Export Document"; var DocumentRecRef: RecordRef; var Picked: Boolean; var IsHandled: Boolean). It lets an app that stores its own posted documents offer them to the field assignment test. Without a subscriber the test can only pick from the document types this app knows about.

The Create Extension action on the field catalogue writes the subscriber for you: it downloads a small AL extension for the selected field, and creates the assignment with the source type Extension that it answers for if there is none yet, and switches it on. Until the extension is installed, the document's payload provenance says that no subscriber answered.

A document type an extension adds also needs its posted tables, so that condition and value rules can be evaluated against them - supply them by subscribing to OnGetPostedTablesForDocType. Without it, rules are not available for that document type.

Together these three interfaces plus the integration event cover the main extension scenarios: new document type (Doc Exporter + Export Document enum), custom model reading (Doc Reader V2), and custom validation (IValidation Rule + Validation Rule enum, registered via OnCollectValidationRules). Field assignments add the two events described above, for a value that has to be calculated in code.