AIF Integration in AX 2012: Inbound Sales Order Message Generator for the File System Adapter
This generator builds an AIF inbound XML message for the SalesOrderService create operation in Dynamics AX 2012, ready to drop into the folder of an enhanced inbound port that uses the file system adapter. A second block lists the port, data policy and batch settings and where to look when the order does not appear.
Fill in
SalesOrderService create message (save as SO_0001.xml in the inbound folder)
<?xml version='1.0' encoding='utf-8'?>
<Envelope xmlns='http://schemas.microsoft.com/dynamics/2011/01/documents/Message'>
<Header>
<MessageId>{7B1E3C52-9A4D-4F0B-8E21-5C6D9A0F3B17}</MessageId>
<Company>usmf</Company>
<Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesOrderService/create</Action>
</Header>
<Body>
<MessageParts>
<SalesOrder xmlns='http://schemas.microsoft.com/dynamics/2008/01/documents/SalesOrder'>
<SalesTable class='entity'>
<CustAccount>US-001</CustAccount>
<DeliveryDate>2026-11-15</DeliveryDate>
<PurchOrderFormNum>PO-7781</PurchOrderFormNum>
<ReceiptDateRequested>2026-11-15</ReceiptDateRequested>
<SalesLine class='entity'>
<ItemId>1000</ItemId>
<SalesQty>25</SalesQty>
<SalesUnit>ea</SalesUnit>
<InventDim class='entity'>
<InventLocationId>11</InventLocationId>
<InventSiteId>1</InventSiteId>
</InventDim>
</SalesLine>
</SalesTable>
</SalesOrder>
</MessageParts>
</Body>
</Envelope>Processing checklist
1. Inbound port: System administration > Setup > Services and Application Integration Framework > Inbound ports. Adapter = File system adapter, URI = the inbound folder, Response address = an outbound folder. Service operation SalesSalesOrderService.create selected. Port activated.
2. Data policies: Customize documents > Data policies. Enable CustAccount, ItemId and every element you send (DeliveryDate, PurchOrderFormNum, ReceiptDateRequested, SalesQty, SalesUnit, InventDim/InventSiteId, InventDim/InventLocationId).
3. Batch job: System administration > Inquiries > Batch jobs > Batch jobs. One recurring job with four tasks: AifGatewayReceiveService, AifInboundProcessingService, AifOutboundProcessingService, AifGatewaySendService. Status Waiting; a 1 minute recurrence is convenient for testing.
4. Drop the file. Files are processed in file name order, so name them SO_0001.xml, SO_0002.xml.
5. Check the response file in the outbound folder: a SalesId in EntityKeyList means the order was created; RequestMessageId equals {7B1E3C52-9A4D-4F0B-8E21-5C6D9A0F3B17}.
6. If nothing appears: System administration > Periodic > Services and Application Integration Framework > Queue manager (message status) and Exceptions (error text, for example a disabled data policy element or an unknown item).Verify on your system: the namespaces are http:// URIs and must match exactly. Header Company must be a company the port allows (or remove it to use the port or submitting user default). Elements inside each entity follow the schema sequence, which for the sales order document is field names in alphabetical order followed by child entities, so keep InventDim after the SalesLine fields and InventLocationId before InventSiteId. Download the schema from the port (Document data policies or the service WSDL) to confirm. Use a new GUID in MessageId for every file; AIF rejects duplicates.
AIF messages failing in Exceptions?
Send us an anonymised message and the exception text, and we will tell you which element, policy or setup is blocking it.
Optional. The tool and every export work without this. No spam.
How to use it
Generate a fresh GUID for MessageId (PowerShell: [guid]::NewGuid()), fill in a real customer account, item, unit, site and warehouse for the target company, and copy the XML into a UTF-8 file. Save it to the inbound folder configured on the port. Within one or two batch cycles AX picks up the file, creates the sales order and writes a response with the new SalesId to the response folder. To send more orders, change MessageId and the values, and name files in sequence because the adapter processes them in file name order.
Where this lives in AX 2012
Enhanced integration ports live under System administration > Setup > Services and Application Integration Framework > Inbound ports. The file system adapter is asynchronous, so messages wait in the AIF queue until the AIF batch tasks run: AifGatewayReceiveService reads the folder, AifInboundProcessingService calls the service, AifOutboundProcessingService builds the response and AifGatewaySendService writes it out. Message status is in the Queue manager and errors in Exceptions, both under System administration > Periodic > Services and Application Integration Framework.
- Service operation: SalesSalesOrderService.create
- Document: SalesOrder with SalesTable and SalesLine entities
- Each element sent must be enabled in Data policies
- Response correlates through RequestMessageId
Worked example
Customer US-001 sends PO-7781 for 25 ea of item 1000, wanted on 2026-11-15 from site 1 warehouse 11. The generated file sets CustAccount US-001, PurchOrderFormNum PO-7781 (the customer requisition shown on the order), ReceiptDateRequested and DeliveryDate 2026-11-15, and one SalesLine with InventDim site and warehouse. After processing, the response contains KeyField SalesId with the new order number. Opening Accounts receivable > Common > Sales orders shows the order with the customer reference filled in.
Version differences and gotchas
The envelope namespace is 2011/01 while the service action and document namespaces are 2008/01; mixing them up is the most common cause of a silent failure. Required fields and defaults depend on the port's document data policy and the customer and item setup; if the item uses product dimensions such as configuration or size, add those InventDim elements and enable them. In AX 2012 R2 and R3 partitions apply; a port restricted to one company or partition rejects messages for others. Duplicate MessageId values are rejected, so never reuse a file.
Frequently Asked Questions
How does AIF integration work in AX 2012?
An integration port exposes service operations such as SalesSalesOrderService.create through an adapter: file system, MSMQ, BizTalk or web services. Asynchronous adapters such as the file system adapter put messages in the AIF queue, and four AIF batch tasks receive, process, build responses and send them. Data policies control which XML elements are accepted.
What XML format does AX 2012 AIF expect for a sales order?
An Envelope in the 2011/01 Message namespace with a Header (MessageId and Action) and a Body containing MessageParts. Inside is a SalesOrder document in the 2008/01 SalesOrder namespace with SalesTable and nested SalesLine entities, each marked class='entity'. This tool generates that structure.
Why is my AIF file not picked up from the folder?
Usually the batch job is not running or lacks the AifGatewayReceiveService task, the port is not activated, or the AOS service account cannot read the folder. Check the batch job status, the port, and folder permissions for the AOS account. Then check Queue manager and Exceptions for messages that were read but failed.
Can I reuse the same MessageId?
No. AIF uses MessageId to detect duplicates and will reject a message whose ID was already processed. Generate a new GUID for every file. The response carries your MessageId in RequestMessageId so the sending system can match responses to requests.
If you want a private AI assistant that drafts and validates AIF messages or answers questions about your AX 2012 orders on your own servers, we can set that up.
Related Tools
Dynamics AX 2012 SQL Reporting Query Generator (DATAAREAID, PARTITION, Enums)
Builds T-SQL for an AX 2012 R2/R3 business database: sales lines with status labels and customer names, filtered by company and partition, plus table and field IDs from SQLDICTIONARY.
Microsoft DynamicsDynamics AX 2012 X++ Table Methods Reference
The xRecord methods you override or call on an AX 2012 table, when the kernel calls each one, and the find/exist conventions, with tips that keep set-based operations fast.
Microsoft DynamicsAX 2012 Table to D365 Data Entity Reference
Look up the D365 F&O data entity and OData collection that corresponds to a Dynamics AX 2012 table when planning data migration.
Microsoft DynamicsAX 2012 to D365 Data Entity Mapping Worksheet
Plan each AX 2012 data object, its D365 data entity, load sequence, record count and owner in one editable migration sheet.
More Microsoft Dynamics tools
See all- AX 2012 to D365 Finance and Operations Upgrade Effort Estimator
- Dynamics AX Customization Inventory Worksheet
- Dynamics AX 2012 Retirement Project Charter Template
- AX 2012 Customization Remediation Effort Calculator
- Dynamics AX 2012 R3 Safety Stock Journal Minimum Calculator
- D365 F&O Manufacturing Data Entities Reference
- D365 F&O OData URL Builder
- D365 Production Order Status Reference
- D365 Data Management Import Worksheet Template
Keep exploring
Free tools
- Dynamics AX 2012 Private AI Layer Blueprint GeneratorFill in your AX 2012 environment and get an architecture plan for a private AI assistant, with components, controls, a 3-phase rollout and open questions for IT.
- Dynamics AX Customization Inventory WorksheetEditable inventory of AX customizations with layer, disposition and rework estimate per object, totaled for upgrade planning.
- Dynamics AX 2012 AI Assistant Sizing and Value CalculatorSize the GPUs, retrieval index and monthly value of a private AI assistant for AX 2012 from your user count and question volume.
ERP fixes and how-tos
- Adding a Private AI Layer to Dynamics AX 2012 On-PremAdd AI to Dynamics AX 2012 on-prem without moving data: SQL replica, AIF services, retrieval index, local LLM, mirrored AX roles, approved write-back.
- Planning an AX 2012 to Dynamics 365 Finance and Operations upgradeHow an AX 2012 to Dynamics 365 Finance and Operations upgrade actually runs: LCS upgrade project, code upgrade of customizations, and data migration, with the main risks.
- Fixing "The CIL object was not found" in Dynamics AX 2012AX 2012 throws CIL object not found after code changes. What CIL generation actually does, why incremental CIL misses it, and the full rebuild fix.
Integrations
- How to add AI agents to Microsoft Dynamics AX 2012How to add AI agents to Dynamics AX 2012 using AIF services, SQL read paths and approval gates, without a forced move to Dynamics 365 first.
- How to automate email-to-transaction in Dynamics AX 2012Turn inbound POs, RFQs, invoices and confirmations into Dynamics AX 2012 transactions: shared inbox parsing, AIF import, staging tables and human review.