> For the complete documentation index, see [llms.txt](https://docs.riff.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.riff.ai/integrations/native-integrations-v2/dynamics-365.md).

# Microsoft Dynamics 365

Connect Riff to Microsoft Dynamics 365 Finance & Operations (F\&O) or Business Central to give your apps and agents live access to purchase orders, vendor invoices, inventory transactions, and cost centres.

## What you connect

Riff connects to Dynamics 365 using **Microsoft Azure Active Directory (Entra ID) OAuth 2.0** and the **Dynamics 365 OData REST API**. Authentication is via a registered Azure AD application with the correct Dynamics permissions.

**Credentials needed:**

| Credential        | Where to find it                                                                   |
| ----------------- | ---------------------------------------------------------------------------------- |
| Tenant ID         | Azure Portal → Azure Active Directory → Properties                                 |
| Client ID         | Azure Portal → App Registrations → your app                                        |
| Client Secret     | Azure Portal → App Registrations → your app → Certificates & Secrets               |
| Dynamics base URL | Your Dynamics environment URL (e.g. `https://yourcompany.operations.dynamics.com`) |

## What your apps and agents can read

| Dynamics entity        | OData path                           | Common use                                      |
| ---------------------- | ------------------------------------ | ----------------------------------------------- |
| Purchase Orders        | `PurchaseOrderHeadersV2`             | Confirmation status, delivery dates, totals     |
| Purchase Order Lines   | `PurchaseOrderLinesV2`               | Line items, quantities, prices, delivery dates  |
| Vendor Invoices        | `VendorInvoiceHeaderEntity`          | Invoice headers, approval status, payment terms |
| Vendor Invoice Lines   | `VendorInvoiceLineEntity`            | Line amounts, quantities, GL codes              |
| Inventory Transactions | `InventTransEntity`                  | Goods receipts, issues, adjustments             |
| Vendors                | `VendorsV2`                          | Vendor contacts, payment terms, currency        |
| Cost Centres           | `DimensionAttributeValueCombination` | Cost centre codes and descriptions              |

## What your agents can do

| Action                     | Example                                                                    |
| -------------------------- | -------------------------------------------------------------------------- |
| **Chase PO confirmations** | Query unconfirmed POs → send confirmation request to vendor → log response |
| **Invoice matching**       | Match vendor invoice lines against PO lines → approve or flag variances    |
| **Delivery monitoring**    | Track PO lines past due date with no inventory transaction → alert buyer   |
| **Cost centre reporting**  | Pull actuals vs. budget by cost centre → flag overspend                    |
| **Vendor performance**     | Calculate on-time delivery and invoice accuracy rates by vendor            |

## App use cases

### Purchase Order Status Tracker

Build an App that reads open POs from Dynamics 365 and shows confirmation status, expected delivery, and receipt status in a clean table. Buyers filter by vendor, site, or category. One-click to send a chase email or escalate to management — no Dynamics login needed.

### Vendor Invoice Approval Queue

Display pending vendor invoices with matched PO and goods receipt data side by side. AP clerks review, approve matched invoices, and route exceptions. The app posts approvals back to Dynamics via the OData API.

### Cost Centre Spend Dashboard

Pull cost centre actuals and budgets from Dynamics. Show year-to-date spend, remaining budget, and top cost categories. Finance managers drill down by GL code or cost centre. Automated weekly digest emailed to cost centre owners.

## Agent use cases

### Vendor Invoice Matching Agent

**Trigger:** Daily at 06:00\
**Input:** All open vendor invoices in Dynamics awaiting approval\
**Action:** Match each invoice line against the corresponding PO line and inventory transaction\
**Output:** Approve matched invoices automatically; escalate variances to AP with a match summary

### Overdue Delivery Monitor

**Trigger:** Daily at 07:00\
**Input:** PO lines where requested delivery date is before today and no inventory transaction posted\
**Action:** Group by vendor; calculate financial exposure; send chase request via Outlook\
**Output:** Slack digest to procurement team with unresolved items flagged for escalation

### Monthly Cost Centre Variance Report

**Trigger:** First working day of each month, 07:30\
**Input:** Cost centre actuals vs. budgets from Dynamics for the prior month\
**Action:** Calculate variance by cost centre and GL account; identify top overruns\
**Output:** Formatted report emailed to Finance team; exceptions flagged for cost centre owners

## Connecting Dynamics 365 in Riff

1. In Azure Portal, register a new application under your tenant's App Registrations
2. Assign the application the **Dynamics 365** API permission: `user_impersonation` (or appropriate application permission for unattended access)
3. Create a client secret and note the Tenant ID, Client ID, and Client Secret
4. Open **Secrets** in Riff and store all four credentials
5. In your app or agent, reference the secrets to authenticate via OAuth 2.0 and call the OData API
6. Ask your agent: *"Read all open purchase orders from Dynamics 365 where the delivery date is in the past and no inventory transaction has been posted"*

{% hint style="info" %}
**F\&O vs. Business Central:** The OData entities above are for Dynamics 365 Finance & Operations. Business Central uses a different OData V4 API (`/api/v2.0/`). The connection approach is the same; entity names and paths differ — check the [Business Central API reference](https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/) for BC-specific entities.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.riff.ai/integrations/native-integrations-v2/dynamics-365.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
