AdvancedMicrosoft Dynamics AX 2012Data access / AIF / SQL Server / Security

Adding a Private AI Layer to Dynamics AX 2012 On-Prem

Question
how to add AI to Dynamics AX 2012 on-prem

Also searched as

  • Dynamics AX 2012 AI integration without cloud
  • AX 2012 local LLM chat over sales orders and inventory
  • AX 2012 private AI architecture SQL Server AIF
  • AX 2012 ChatGPT alternative on premises

Short answer

You can put a useful AI assistant on Dynamics AX 2012 without sending anything to a cloud: read from a SQL Server replica, expose a short list of approved read actions through a tool server, serve an open-weight model on local GPUs, and mirror AX security roles so answers respect what each user may see. Write-back stays human-approved and goes through AX services, never direct SQL.

Applies to: Dynamics AX 2012 (RTM, R2, R3) on SQL Server, any hosting that lets you add a read-only SQL replica and an application server on the same network

How to stand up a private AI layer on AX 2012

  1. 1Inventory what the assistant must answer: open sales and purchase orders, item availability, customer balances, production status, attached documents. Rank by how often people ask a colleague today.
  2. 2Create a read-only copy of the AX business database: an AlwaysOn readable secondary, log shipping with standby, or a nightly restore. Point all assistant queries at it, never at the production AOS database.
  3. 3Create a dedicated SQL login with SELECT on a small set of views you own in a separate schema. Do not grant db_datareader on the whole database.
  4. 4Export and map metadata: table and field names from SQLDictionary, enum integers to labels, and DATAAREAID and PARTITION values, so the model sees readable columns.
  5. 5Build a retrieval index over attachments (DocuRef and DocuValue), item descriptions, work instructions on file shares and any SSRS report text you want searchable.
  6. 6Stand up a tool server that exposes named read actions (get_open_sales_orders, get_item_availability) with parameter validation, and let the model call only those.
  7. 7Serve an open-weight model with vLLM or Ollama on local GPUs, wire the audit log, then pilot with ten users on read-only questions before enabling drafts.

Real data access paths in AX 2012

AX 2012 stores business data in a single SQL Server database per environment. Almost every table carries DATAAREAID (the legal entity), PARTITION (the AX partition, with the initial partition having a well-known RecId) and RECID. Main tables you will touch first are CUSTTABLE, VENDTABLE, INVENTTABLE, SALESTABLE, SALESLINE, PURCHTABLE, PURCHLINE, CUSTTRANS, INVENTTRANS and INVENTSUM. Enums are stored as integers, so an assistant needs a mapping from the AOT enum definitions to labels or it will misread status columns.

SQLDICTIONARY maps AX table and field ids to SQL names, which matters when you generate queries from natural language. For supported programmatic access AX 2012 offers the Application Integration Framework (AIF) with document services such as the sales order service, custom X++ services published through service groups on the AOS, and the Query service. Direct SQL on a replica is the pragmatic read path for analytics-style questions; services are the right path whenever business logic, security or posting rules matter.

-- Read-only: open sales order lines for one legal entity and the initial partition
SELECT st.SALESID, st.CUSTACCOUNT, st.SALESSTATUS, sl.ITEMID,
       sl.SALESQTY, sl.REMAINSALESPHYSICAL, sl.LINEAMOUNT
FROM   SALESTABLE st
JOIN   SALESLINE  sl ON sl.SALESID = st.SALESID
                    AND sl.DATAAREAID = st.DATAAREAID
                    AND sl.PARTITION  = st.PARTITION
WHERE  st.DATAAREAID = 'usmf'
  AND  st.PARTITION  = 5637144576   -- initial partition
  AND  st.SALESSTATUS = 1           -- backorder (open); confirm against your enum
ORDER BY st.SALESID;

Reference architecture, including the air-gapped option

Keep five components inside your network. A read-only replica or reporting copy of the AX database, optionally fed by change data capture or SQL Server change tracking so the retrieval index updates incrementally. A retrieval index over documents and text fields, using a local vector store or a SQL Server or PostgreSQL extension. A tool server, typically an MCP server, that exposes approved read actions. An open-weight model (Llama, Qwen, Mistral, Gemma, gpt-oss class) served by vLLM or Ollama on local GPUs. And an audit log recording user, question, tool calls, SQL or service request and answer.

For an air-gapped site, nothing in that list needs the internet: models and Python or container packages are brought in through a controlled transfer, the replica is refreshed from backups inside the enclave, and the audit log stays local. The trade-off is operational: you own patching, model updates and evaluation, so schedule them like any other server maintenance.

{
  "name": "get_open_sales_orders",
  "description": "Read-only. Open sales order lines for a customer account in one legal entity.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "dataAreaId": { "type": "string", "maxLength": 4 },
      "custAccount": { "type": "string", "maxLength": 20 },
      "maxRows": { "type": "integer", "maximum": 200 }
    },
    "required": ["dataAreaId", "custAccount"]
  }
}

Permissions and write-back

AX 2012 security is role based: users are assigned security roles, roles contain duties, duties contain privileges that grant entry points, and extensible data security (XDS) policies filter records by constraint. Role assignments live in AX tables such as SecurityUserRole. The assistant should resolve the signed-in Windows user to an AX user, read their roles and legal entities, and pass those as filters inside every tool call. Because direct SQL bypasses XDS, either reimplement the relevant constraints in your views or send those questions through AX services that enforce them.

Write-back is a separate, later phase. Let the assistant draft a purchase requisition or a customer note, show it to the user, and on approval post it through a supported AIF document service or a custom X++ service so validation, number sequences and workflow still run. Never write to AX tables with SQL, and never let the model decide on its own to submit.

Sizing, phased rollout and honest limits

A 100 to 300 user AX estate typically needs one to two inference GPUs for an 8B to 32B class model, plus a modest server for the index and tool server; a few hundred thousand documents usually index into single-digit to low tens of gigabytes. Treat these as starting ranges and size from your own question volume with the calculator linked on this site. Roll out in three phases: read-only questions for a pilot group, then drafts that a person reviews, then a small set of approved actions.

Be honest about limits. AX 2012 is out of mainstream support, so any new integration should be weighed against your Dynamics 365 plan; an assistant built on stable SQL views and a tool server moves with you, but X++ service customizations will not. Free-text answers about posting logic or inventory costing will be only as good as the documentation you index. If your need is simply scheduled reports, SSRS and Power BI are enough and an LLM adds cost without value.

Try it here, free

Dynamics AX 2012 AI Assistant Sizing and Value Calculator

Open full tool

Size the GPUs, retrieval index and monthly value of a private AI assistant for AX 2012 from your user count and question volume.

Common pitfalls

  • !Querying the production AOS database for assistant traffic. Long scans compete with order entry; always use a replica.
  • !Ignoring DATAAREAID and PARTITION in joins, which returns rows from other legal entities and breaks both accuracy and confidentiality.
  • !Giving the model raw enum integers. It will guess labels. Map enums from the AOT metadata and test the mapping.
  • !Using db_datareader for the assistant's login. Grant SELECT only on curated views so new sensitive tables are not exposed by default.
  • !Bypassing XDS policies in direct SQL and assuming role filters are enough. Re-check any constrained table before exposing it.

How an ERP-grounded AI assistant handles this

Netray's ERPray approach for older Microsoft estates uses this pattern: read-only by default, the generated SQL or service call is shown with every answer, AX roles are mirrored, and the model runs on your hardware. It is a custom build per estate, not a packaged AX connector, so the first week is spent confirming which tables, views and services your users actually rely on.

Frequently asked questions

Can AX 2012 use Microsoft Copilot?

Microsoft's Copilot features are built for current cloud-hosted Dynamics products, not for AX 2012. If you want natural-language access to AX 2012 data, you build it yourself on a replica and a local model, which is also what keeps data inside your network.

Is reading the AX database directly supported?

Reading with SELECT from a replica is a common practice for reporting, but it bypasses AX business logic and XDS security. Use curated views and mirrored roles, and prefer AIF or X++ services whenever rules or security matter.

Which model size is enough for AX questions?

Most lookup and summarisation questions work with an 8B to 32B open-weight model when retrieval and the tool server are well built. Larger models help with complex multi-step questions. Test against your own question set before buying GPUs.

Should we do this instead of upgrading to Dynamics 365?

It depends on your timeline. A read-only AI layer can deliver value in weeks and lets you keep AX running, but it does not remove support risk. Design the views and tool server so they can be repointed to a successor system.

Related

Advanced

Adding a Private AI Layer to Dynamics NAV On-Prem

Dynamics NAV can feed a private AI assistant through two safe doors: a read-only SQL Server copy for analytical questions and published web services (OData and SOAP) for anything that must respect NAV logic and permissions. Put an open-weight model and a retrieval index beside them on your own hardware and keep writes behind human approval and codeunit-based services.

Advanced

Adding a Private AI Layer to Dynamics GP On-Prem

Dynamics GP is an easy system to read from and a delicate one to write to. Read from curated SQL views on a replica of the company database, search documents with a local retrieval index, serve an open-weight model on your own GPU, and send any write through eConnect or another supported integration after a person approves it.

Advanced

Planning an AX 2012 to Dynamics 365 Finance and Operations upgrade

Moving from AX 2012 to D365 F&SCM is a platform change, not a version bump: X++ customizations go through a code upgrade to the new extension/overlayering model, and data moves through a structured data migration, both coordinated as an Upgrade project in Lifecycle Services (LCS). Plan it as a project with its own testing cycle, not a routine patch.

Error fix

Fixing "The CIL object was not found" in Dynamics AX 2012

This error appears when the AOS tries to execute compiled CIL for a class or method that has not actually been regenerated since a code change was imported or edited, so the .NET runtime has nothing matching to run. The fix is a full compile followed by a full CIL generation and an AOS restart, not just a partial or incremental rebuild.

Error fix

Fixing "Cannot create a record in (table). The record already exists" in D365 F&SCM data entity imports

This is the standard kernel duplicate-key exception, thrown when the Data Management Framework tries to insert a staging row into a target table whose unique or alternate key already matches an existing record. It almost always means the entity's insert-vs-update logic did not recognize the target row as an update, not that you have a true accidental duplicate in your source file.

Error fix

Fixing "There are currently no batch servers available for processing" in D365 F&SCM

This message means the batch framework cannot find any AOS instance flagged as a batch server and available for the batch group the job is assigned to. The fix is almost always in server configuration (System administration > Servers) or batch group assignment, not in the batch job itself.

AI for ERP

AI for Dynamics AX 2012, Without the Forced Migration

Dynamics AX 2012 R3 left mainstream support in 2021. Add a private LLM over AX data now, use it to de-risk a future migration, without a forced move to D365.

AI for ERP

AI Agents for ERP, Running On-Prem

A practical guide to on-prem AI agents for ERP: what they can safely automate, where human approval belongs, and how to design the guardrails.

Stuck on Microsoft Dynamics AX 2012?

Talk to engineers who work inside Microsoft Dynamics AX 2012 every week, and who build private AI that answers these questions from your own ERP data.

Keep exploring

Free tools

ERP fixes and how-tos

AI on your ERP

Integrations