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
| Product | Supported Versions | Primary API |
|---|---|---|
| Dynamics 365 Business Central | 2023 Wave 2 (v23), 2024 Wave 1 (v24), 2024 Wave 2 (v25) | AL extensions, API v2.0, OData, SOAP |
| Dynamics 365 Finance & Operations | 10.0.36 / 10.0.40 / 10.0.41+ | OData, Data Management Framework, Recurring exports |
| Power Platform | Power Automate, Logic Apps | Connectors + 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.
- Invoice posted in Dynamics 365 (Business Central Sales Invoice or F&O Customer Invoice).
- Extension / middleware / export transforms the invoice to TrustBill's JSON shape.
- POST to TrustBill
/api/v1/invoiceswith API key authentication. - TrustBill validates the payload, renders PINT-AE XML and delivers over Peppol via the FTA-accredited ASP.
- 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/jsonFor 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_credentialsFor 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,CurrencyCodeWith 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 Field | TrustBill JSON | Notes |
|---|---|---|
No. / InvoiceNumber | invoiceNumber | Unique per seller |
Posting Date / InvoiceDate | issueDate | ISO-8601 |
Company.TRN | seller.trn | 15-digit UAE TRN |
Customer.TRN / VAT | buyer.trn | Required for B2B |
Sales Invoice Line.Description | items[].name | English + Arabic if available |
Quantity | items[].quantity | Positive numeric |
Unit Price | items[].unitPrice | After line discount |
Amount Including VAT | totals.grossAmount | VAT inclusive |
UAE VAT / Tax Mapping
Map Dynamics 365 tax groups / VAT product posting groups to FTA tax category codes.
| D365 Tax Group / Posting Group | TrustBill taxCategory | Rate |
|---|---|---|
| VAT 5% | STANDARD | 5% |
| VAT 0% | ZERO_RATE | 0% |
| Exempt | EXEMPT | — |
| Reverse Charge | REVERSE_CHARGE | 5% |
| Out of Scope | OUT_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.
| Mode | Endpoint / Option | What it does |
|---|---|---|
| Sandbox | ?mode=sandbox or bulk import sandbox | Validates PINT-AE, no FTA delivery |
| Live | ?mode=live | Submits 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 Status | Meaning | Action |
|---|---|---|
| 400 | Malformed JSON or missing required field | Fix the AL/Power Automate mapping; do not retry unchanged |
| 401 | Invalid or expired API key / Entra ID token | Rotate the key or refresh the app registration secret |
| 403 | TRN on invoice does not match the API key's registered TRN | Fix company/legal-entity → TRN mapping |
| 409 | Duplicate invoice number for this seller | Check idempotency key / posted invoice number reuse |
| 422 | PINT-AE validation failure (tax, TRN format, totals mismatch) | Inspect errors[] array; fix mapping |
| 429 / 5xx | Rate limited or TrustBill/FTA temporarily unavailable | Retry 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.Allor 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
CustInvoiceJourand that the entity is enabled for OData. - Missing Arabic names: Use a custom field or the
Description 2field 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.