> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Dynamics 365 Finance and Supply Chain

> Client-mode REST API connector for a curated Dynamics 365 F&O OData slice: ProductionOrderHeaders, ReportAsFinishedProductionJournalEntries, InventoryMovementJournalEntries, AssetMaintenanceRequestsV2

Technical Preview

## Overview

A client-mode connector for a **curated manufacturing / inventory / maintenance** slice of [Dynamics 365 Finance & Operations OData](https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/odata) under `https://{env}.operations.dynamics.com/data/`:

| Catalog connector event | Entity / path | Notes |
| - | - | - |
| GET ProductionOrderHeaders | `ProductionOrderHeaders` | Production order headers; supports `$filter`, `cross-company` |
| POST ProdReportAsFinished | `ReportAsFinishedProductionJournalEntries` | Report-as-finished production journal entries ([dynamics.fo](https://dynamics.fo/data-entity/report-finished-production-journal-entries)) |
| POST InventoryJournalLines | `InventoryMovementJournalEntries` | Inventory movement journal headers/lines; confirm PublicCollectionName on tenant `$metadata` (V1/V2 obsolete; V3 in CDM) |
| GET MaintenanceRequests | `AssetMaintenanceRequestsV2` | Asset management maintenance requests V2 (10.0.32+) |

`BASE_ADDRESS` is the F\&O OData root (`https://{env}.operations.dynamics.com/data`). Topics use `erp/dynamics365-fscm/<object>/<verb>`.

> [!NOTE]
>
> This is **Finance & Operations / Supply Chain**, not Dataverse. For CRM Web API (accounts, incidents, Field Service), see [Dynamics 365 (Dataverse)](/latest/lot-language/routes/rest-api-apps/dynamics365).

> [!NOTE]
>
> F\&O OData requires a real environment URL and an Entra ID OAuth 2.0 Bearer token (client credentials). This template has not been verified against a live tenant. Prefer Hub secrets for tokens. Discover public entities with `GET .../data/` or `GET .../data/$metadata`.

## Basic Syntax

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
# Coreflux REST_API template — Microsoft Dynamics 365 Finance and Supply Chain (F&O OData slice)
# Auth: Bearer {value.json.access_token} (Entra ID client credentials)
# BASE_ADDRESS: https://YOUR_ENV.operations.dynamics.com/data

DEFINE ROUTE Dynamics365FscmRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://YOUR_ENV.operations.dynamics.com/data"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT Getproductionorderheaders
        WITH SOURCE_TOPIC "erp/dynamics365-fscm/production-order-headers/get"
        WITH DESTINATION_TOPIC "erp/dynamics365-fscm/production-order-headers/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/ProductionOrderHeaders?cross-company=true&$top={value.json.top}&$filter={value.json.filter}&$select={value.json.select}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "OData-MaxVersion" "4.0"
            ADD "OData-Version" "4.0"
            ADD "Authorization" "Bearer {value.json.access_token}"
    ADD EVENT Createprodreportasfinished
        WITH SOURCE_TOPIC "erp/dynamics365-fscm/prod-report-as-finished/create"
        WITH DESTINATION_TOPIC "erp/dynamics365-fscm/prod-report-as-finished/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/ReportAsFinishedProductionJournalEntries"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "OData-MaxVersion" "4.0"
            ADD "OData-Version" "4.0"
            ADD "Authorization" "Bearer {value.json.access_token}"
        WITH BODY "{payload}"
    ADD EVENT Createinventoryjournallines
        WITH SOURCE_TOPIC "erp/dynamics365-fscm/inventory-journal-lines/create"
        WITH DESTINATION_TOPIC "erp/dynamics365-fscm/inventory-journal-lines/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/InventoryMovementJournalEntries"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "OData-MaxVersion" "4.0"
            ADD "OData-Version" "4.0"
            ADD "Authorization" "Bearer {value.json.access_token}"
        WITH BODY "{payload}"
    ADD EVENT Getmaintenancerequests
        WITH SOURCE_TOPIC "erp/dynamics365-fscm/maintenance-requests/get"
        WITH DESTINATION_TOPIC "erp/dynamics365-fscm/maintenance-requests/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/AssetMaintenanceRequestsV2?cross-company=true&$top={value.json.top}&$filter={value.json.filter}&$select={value.json.select}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "OData-MaxVersion" "4.0"
            ADD "OData-Version" "4.0"
            ADD "Authorization" "Bearer {value.json.access_token}"

```

## Events

| Event | Method | Endpoint | Request topic | Response topic |
| - | - | - | - | - |
| Getproductionorderheaders | GET | `/ProductionOrderHeaders` | `erp/dynamics365-fscm/production-order-headers/get` | `erp/dynamics365-fscm/production-order-headers/get/response` |
| Createprodreportasfinished | POST | `/ReportAsFinishedProductionJournalEntries` | `erp/dynamics365-fscm/prod-report-as-finished/create` | `erp/dynamics365-fscm/prod-report-as-finished/create/response` |
| Createinventoryjournallines | POST | `/InventoryMovementJournalEntries` | `erp/dynamics365-fscm/inventory-journal-lines/create` | `erp/dynamics365-fscm/inventory-journal-lines/create/response` |
| Getmaintenancerequests | GET | `/AssetMaintenanceRequestsV2` | `erp/dynamics365-fscm/maintenance-requests/get` | `erp/dynamics365-fscm/maintenance-requests/get/response` |

## Auth

**OAuth 2.0 client credentials (Entra ID) — default in the template:**

1. Register an app in Microsoft Entra ID; create a client secret; grant Dynamics ERP API permissions as required by your tenant.
2. In F\&O: **System administration > Setup > Microsoft Entra applications** — add the client ID and map it to a service user.
3. Request a token:

```http theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id={clientId}&client_secret={secret}&scope=https://{env}.operations.dynamics.com/.default
```

4. Pass the access token on the MQTT request payload:

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{"access_token": "YOUR_ENTRA_ACCESS_TOKEN", "top": "10", "filter": "ProductionOrderStatus eq Microsoft.Dynamics.DataEntities.ProdStatus'Started'", "select": "ProductionOrderNumber,ProductionOrderStatus,ItemNumber"}
```

The connector sends `Authorization: Bearer {value.json.access_token}`. Prefer Hub secrets / `GET SECRET`. Never commit real tokens.

## Cross-company and keys

By default OData returns only the service user's default company. The GET endpoints append `cross-company=true`. To filter one company: `$filter=dataAreaId eq 'usmf'` with `cross-company=true`. Entity keys usually include `dataAreaId` plus a business key (e.g. `ProductionOrderNumber`) — see Microsoft Learn OData addressing.

## Entity name notes

Public collection names can differ by F\&O version. This package uses documented PublicCollectionName values from [dynamics.fo](https://dynamics.fo/) and community usage. Always confirm on your tenant with `GET https://{env}.operations.dynamics.com/data/$metadata` or Excel workbook designer. Report-as-finished and inventory journal **posting** may require a bound OData action after create — loading the journal line alone does not always post.

## Deploy

1. Copy `Dynamics365FscmRestApi.lot` (no `ADD METADATA`).
2. Replace `YOUR_ENV` in `BASE_ADDRESS`.
3. `-addRoute` on the broker (or Hub deploy).
4. Publish JSON to a request topic; subscribe to the matching `/response` topic.

Hub catalog metadata (icon, description, `STATUS "beta"`) is in `hub-metadata.lot` for Hub / `-listTemplates` only.

## Status

**Blocked** until a live authenticated call succeeds (factory has no F\&O env URL or Entra credentials). Unblock with lab env URL + client-credentials token, then smoke `GET /ProductionOrderHeaders?$top=1&cross-company=true` expecting HTTP 200.

## References

* [Open Data Protocol (OData) — Finance & Operations](https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/odata)
* [Service endpoints overview](https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/services-home-page)
* [Report production orders as finished](https://learn.microsoft.com/en-us/dynamics365/supply-chain/production-control/report-production-orders-as-finished)
* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.