← Back to Documentation
Microsoft Dynamics 365 logo

Microsoft Dynamics 365 Integration with UAE FTA E-Invoicing via TrustBill

Connect Dynamics 365 Business Central and Dynamics 365 Finance & Operations to TrustBill for PINT-AE e-invoicing · AL extensions · OData · Power Automate · Data Management Framework

Overview

This guide explains how to connect Microsoft Dynamics 365 — Business Central and Finance & Operations — to TrustBill, a UAE FTA-accredited service provider (ASP). Invoices posted in Dynamics 365 are sent as PINT-AE compliant e-invoices to the FTA without replacing your ERP.

Dynamics 365 already manages UAE VAT, customer TRNs, item masters, approval workflows and general ledger postings. What it does not ship out of the box is PINT-AE XML generation and delivery through an FTA-accredited ASP over the Peppol network. TrustBill is the connecting layer.

What this integration delivers

  • Submit posted sales invoices and credit notes from Dynamics 365 to the FTA
  • Business Central: AL extension or API v2.0 integration
  • Finance & Operations: OData / Data Management Framework / recurring export
  • Power Automate / Logic Apps option for low-code wiring
  • PINT-AE XML generated, validated and delivered by TrustBill
  • FTA acknowledgement, UUID and QR data written back to custom fields
  • Bulk migration path for historical invoices via Excel add-in, Entity export or CSV

What is Dynamics 365?

Microsoft Dynamics 365 is a modular cloud ERP and CRM suite. The products most relevant for UAE e-invoicing are:

  • Dynamics 365 Business Central — SMB ERP with AL extensions and built-in REST/OData APIs
  • Dynamics 365 Finance & Operations — enterprise ERP with OData, Data Management Framework and dual-write to Dataverse
  • Power Platform — Power Automate and Logic Apps for orchestration; Dataverse as a staging table

Supported Versions

ProductSupported VersionsPrimary API
Dynamics 365 Business Central2023 Wave 2 (v23), 2024 Wave 1 (v24), 2024 Wave 2 (v25)AL extensions, API v2.0, OData, SOAP
Dynamics 365 Finance & Operations10.0.36 / 10.0.40 / 10.0.41+OData, Data Management Framework, Recurring exports
Power PlatformPower Automate, Logic AppsConnectors + HTTP actions

Prerequisites

  • Dynamics 365 tenant with a valid UAE legal entity, TRN and VAT setup
  • Customer records with 15-digit UAE TRN for B2B transactions
  • User / app registration with permissions to read posted invoices and write custom fields
  • Active TrustBill SME account with API credentials
  • Network egress from Dynamics 365 services (or middleware) to TrustBill API endpoints
  • Azure App Registration for OAuth 2.0 client credentials (if using Business Central Online / F&O)

Integration Architecture

Dynamics 365 remains the source of record. Invoices flow to TrustBill either through an extension inside Business Central, an OData-based middleware, or a Data Management export.

  1. Invoice posted in Dynamics 365 (Business Central Sales Invoice or F&O Customer Invoice).
  2. Extension / middleware / export transforms the invoice to TrustBill's JSON shape.
  3. POST to TrustBill /api/v1/invoices with API key authentication.
  4. TrustBill validates the payload, renders PINT-AE XML and delivers over Peppol via the FTA-accredited ASP.
  5. Acknowledgement is written back to custom fields or Dataverse records.

Connection Methods

1. Business Central AL Extension (Recommended for BC)

Write an AL codeunit that subscribes to the sales-invoice posting event and calls the TrustBill REST API withHttpClient.

2. Business Central API v2.0 / OData

Query salesInvoices, salesInvoiceLines and customers endpoints from an external middleware or Logic App.

3. Finance & Operations OData

Use the F&O OData endpoint for CustInvoiceJour / CustInvoiceTrans to pull posted customer invoices.

4. Finance & Operations Data Management Framework

Export invoice data through a recurring Entity export to Azure Blob or SFTP; TrustBill picks the file via a custom connector.

5. Power Automate / Logic Apps

Build a cloud flow that listens for a new invoice in Dataverse or a scheduled trigger, then calls the TrustBill HTTP API.

Authentication

TrustBill API uses Bearer tokens. Dynamics 365 uses Azure Active Directory / Microsoft Entra ID for service-to-service calls.

POST https://trustbill.ae/api/v1/invoices
Authorization: Bearer tb_your_api_key_here
Content-Type: application/json

For Business Central Online, get an Entra ID access token via client credentials:

POST https://login.microsoftonline.com/<tenant>/oauth2/v2.0/token
client_id=<app_id>
&client_secret=<secret>
&scope=https://api.businesscentral.dynamics.com/.default
&grant_type=client_credentials

For F&O, use the same Entra ID flow with scope https://{tenant}.operations.dynamics.com/.default.

Dynamics 365 Business Central

The cleanest Business Central approach is an AL extension that fires after a sales invoice posts and sends the payload to TrustBill.

Step 1: Add custom fields to Sales Invoice Header

  • TrustBill Status (Text[20])
  • TrustBill UUID (Text[50])
  • TrustBill Ack Ref (Text[50])
  • TrustBill Reject Reason (Text[250])

Step 2: AL extension sample

codeunit 50100 "TrustBill E-Invoice"
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post",
        'OnAfterPostSalesDoc', '', false, false)]
    local procedure OnAfterPostSalesDoc(var SalesHeader: Record "Sales Header";
        var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
        SalesShptHdrNo: Code[20]; RetRcpHdrNo: Code[20]; SalesInvHdrNo: Code[20];
        SalesCrMemoHdrNo: Code[20])
    var
        SalesInvHeader: Record "Sales Invoice Header";
        HttpClient: HttpClient;
        HttpContent: HttpContent;
        HttpResponse: HttpResponseMessage;
        JsonBody: Text;
    begin
        if SalesInvHdrNo = '' then
            exit;

        SalesInvHeader.Get(SalesInvHdrNo);
        JsonBody := BuildInvoiceJson(SalesInvHeader);

        HttpContent.WriteFrom(JsonBody);
        HttpContent.GetHeaders().Remove('Content-Type');
        HttpContent.GetHeaders().Add('Content-Type', 'application/json');
        HttpClient.DefaultRequestHeaders().Add('Authorization',
            'Bearer tb_your_api_key');

        HttpClient.Post('https://trustbill.ae/api/v1/invoices',
            HttpContent, HttpResponse);

        if HttpResponse.IsSuccessStatusCode() then
            SalesInvHeader."TrustBill Status" := 'Submitted'
        else
            SalesInvHeader."TrustBill Reject Reason" :=
                Format(HttpResponse.HttpStatusCode);

        SalesInvHeader.Modify(false);
    end;
}

Step 3: API v2.0 approach (no extension required)

GET https://api.businesscentral.dynamics.com/v2.0/<tenant>/<environment>/api/v2.0/companies(<companyId>)/salesInvoices
  ?$expand=salesInvoiceLines,customer
  &$filter=status eq 'Open'

Dynamics 365 Finance & Operations

For F&O, the standard pattern is either OData for real-time queries or the Data Management Framework for scheduled batch export.

GET https://{tenant}.operations.dynamics.com/data/CustomerInvoiceHeaders
  ?$filter=InvoiceNumber eq 'INV-00001'
  &$expand=CustomerInvoiceLines
  &$select=InvoiceNumber,InvoiceDate,DueDate,CustomerAccount,CurrencyCode

With the DMF approach, create an Export Project for the CustomerInvoiceV3 entity, schedule it to export daily, and deliver the file to Azure Blob or SFTP. TrustBill can poll the file and import the invoices in bulk.

Power Automate & Dataverse

If your invoice data is already in Dataverse, a cloud flow can push it to TrustBill with an HTTP action. This is useful for organisations using Dynamics 365 Sales with Project Operations or Field Service.

Trigger: When a row is added, modified or deleted
  → Table: Invoice
  → Scope: Organization

Action: HTTP
  Method: POST
  URI: https://trustbill.ae/api/v1/invoices
  Headers: {
    "Authorization": "Bearer tb_your_api_key",
    "Content-Type": "application/json"
  }
  Body: <TrustBill JSON payload>

Dynamics 365 → TrustBill Field Mapping

Dynamics 365 FieldTrustBill JSONNotes
No. / InvoiceNumberinvoiceNumberUnique per seller
Posting Date / InvoiceDateissueDateISO-8601
Company.TRNseller.trn15-digit UAE TRN
Customer.TRN / VATbuyer.trnRequired for B2B
Sales Invoice Line.Descriptionitems[].nameEnglish + Arabic if available
Quantityitems[].quantityPositive numeric
Unit Priceitems[].unitPriceAfter line discount
Amount Including VATtotals.grossAmountVAT inclusive

UAE VAT / Tax Mapping

Map Dynamics 365 tax groups / VAT product posting groups to FTA tax category codes.

D365 Tax Group / Posting GroupTrustBill taxCategoryRate
VAT 5%STANDARD5%
VAT 0%ZERO_RATE0%
ExemptEXEMPT
Reverse ChargeREVERSE_CHARGE5%
Out of ScopeOUT_OF_SCOPE

Credit Notes

Sales credit memos from Business Central and customer credit notes from F&O are mapped to TrustBill's credit-note endpoint. Include the original invoice number.

POST https://trustbill.ae/api/v1/credit-notes
{
  "originalInvoiceNumber": "INV-00001",
  "issueDate": "2026-09-08",
  "creditNoteNumber": "CM-00001",
  "reason": "Goods return",
  "totals": {
    "grossAmount": -525.00
  }
}

Status Tracking

TrustBill can deliver webhooks to an Azure Function, Logic App or Power Automate flow. The payload includes the invoice number, status and acknowledgement reference.

POST https://your-function.azurewebsites.net/api/trustbill-webhook
Content-Type: application/json

{
  "invoiceNumber": "INV-00001",
  "status": "Acknowledged",
  "ackRef": "FDA-ACK-123456789",
  "uuid": "a1b2c3d4-...",
  "reason": null
}

The receiver then updates the custom fields in Business Central (AL) or Dataverse / F&O through a reverse API write.

Bulk Migration

For historical invoices, use the Business Central Excel add-in, F&O Data Management export, or OData pagination to extract records. The CSV must match the field mapping table.

POST https://trustbill.ae/api/v1/invoices/bulk
Authorization: Bearer tb_your_api_key
Content-Type: multipart/form-data

file: invoices.csv
options: {"mode":"sandbox","skipErrors":true}

Sandbox & Live Modes

Test the full flow without touching the FTA. Switch to live once FTA registration and ASP assignment are complete.

ModeEndpoint / OptionWhat it does
Sandbox?mode=sandbox or bulk import sandboxValidates PINT-AE, no FTA delivery
Live?mode=liveSubmits to FTA via ASP over Peppol

Multi-Company & Multi-Currency

Business Central and Finance & Operations both support multiple legal entities under one tenant — common for UAE groups running a mainland company and a free-zone company side by side. TrustBill treats each Dynamics 365 company (Business Central) or legal entity (F&O) as an independent seller with its own TRN.

Company → TrustBill profile mapping

Store a mapping of Business Central company ID (or F&O DataAreaId) to TrustBill API key and TRN — either as an AL setup table or a Power Automate environment variable. Never share one TrustBill profile across two legal entities.

Multi-currency invoices

Both products support an "Additional Reporting Currency". When the sales invoice currency code is not AED, include the original currency and amount plus the AED-converted total (using the exchange rate on the posted invoice) in the TrustBill payload — PINT-AE requires an AED figure for FTA reporting regardless of the trading currency.

Intercompany transactions

Intercompany sales between two UAE legal entities in the same tenant still need two separate PINT-AE submissions — one from the selling entity, one recorded on the buying entity's books. Do not merge them into a single TrustBill call.

Error Handling & API Errors

Handle TrustBill responses deterministically inside the AL extension or Power Automate flow — separate retryable errors from permanent validation errors.

HTTP StatusMeaningAction
400Malformed JSON or missing required fieldFix the AL/Power Automate mapping; do not retry unchanged
401Invalid or expired API key / Entra ID tokenRotate the key or refresh the app registration secret
403TRN on invoice does not match the API key's registered TRNFix company/legal-entity → TRN mapping
409Duplicate invoice number for this sellerCheck idempotency key / posted invoice number reuse
422PINT-AE validation failure (tax, TRN format, totals mismatch)Inspect errors[] array; fix mapping
429 / 5xxRate limited or TrustBill/FTA temporarily unavailableRetry with exponential backoff (max ~5 attempts)

Setup Checklist

  • UAE TRN configured for every Business Central company / F&O legal entity
  • Customer master records populated with TRNs for B2B customers
  • AL extension published, or Power Automate flow / API v2.0 access enabled
  • Entra ID app registration created with least-privilege API permissions
  • Company/legal-entity → TrustBill API key mapping table created
  • Tax code → PINT-AE tax category mapping reviewed with finance
  • Credit memo flow mapped to TrustBill credit notes
  • Webhook or polling job configured for status write-back
  • Sandbox invoices tested for standard, zero-rated, exempt and reverse-charge cases
  • Go-live date agreed and live mode switched only after sandbox sign-off

Troubleshooting

  • 422 validation error: Confirm the customer TRN is 15 digits and the company TRN is set on the legal entity.
  • Business Central 401: Ensure the Entra ID app has the Financials.ReadWrite.All or equivalent API permission and admin consent is granted.
  • AL extension not firing: Check that the event subscriber matches the correct posting codeunit and that the extension is published and installed.
  • F&O OData not returning data: Verify the user belongs to a role with access to CustInvoiceJour and that the entity is enabled for OData.
  • Missing Arabic names: Use a custom field or the Description 2 field to store Arabic legal names and include it in the payload.

Support

Need help with the Dynamics 365 integration? Our team can review your AL extension, OData setup, DMF export or Power Automate flow.