> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/action-center/microsoft-dynamics-365/create-dynamics-365-case.md).

# Create Dynamics 365 Case

Creates one Case (an `incident` record) in Microsoft Dynamics 365 Customer Service. The case description lists the matched device assets as comma separated rows. The job signs in to Microsoft Entra with a client secret and calls the Dataverse Web API of your environment.

### Before you begin

* A Dynamics 365 Customer Service environment and its Dataverse URL, for example `https://orgXXXXXXXX.crm.dynamics.com`.
* A Microsoft Entra app registration with a client secret, that is allowed to create Case records in that environment. You need its tenant ID, client ID and client secret value.
* The GUID of an existing account or contact to set as the case customer. Dynamics requires a customer on every case.
* Asset type: **Device** (the only type this job accepts).
* No required columns. The description uses the device columns set for the workflow (see **Edit Columns** in [About Action Center](broken://pages/bb2f624eb1c01048b9f65d24d1c066197ea76607)).
* Defaults: you can save the connection fields once under **Action Center** > **Settings** > **Microsoft Dynamics 365**. See [Action Center Settings](broken://pages/5accddd15304c1af96444dfc064130c453c9989d).

### Settings

| Setting          | Type             | Required | Default      | Description                                                                              |
| ---------------- | ---------------- | -------- | ------------ | ---------------------------------------------------------------------------------------- |
| Organization URL | URL              | Yes      | None         | The Dataverse environment URL, for example `https://orgXXXXXXXX.crm.dynamics.com`.       |
| Tenant ID        | Text             | Yes      | None         | Microsoft Entra directory (tenant) ID.                                                   |
| Client ID        | Text             | Yes      | None         | Entra app registration application (client) ID.                                          |
| Client Secret    | Text (sensitive) | Yes      | None         | Entra app registration client secret value. Masked after saving.                         |
| Customer Type    | Choice           | No       | account      | Whether the case customer is an account or a contact. Choices: account, contact.         |
| Customer ID      | Text             | Yes      | None         | GUID of the existing account or contact to set as the case customer.                     |
| Priority         | Choice           | No       | None         | Optional case priority. Choices: 1 (High), 2 (Normal), 3 (Low).                          |
| Extra Parameters | JSON             | No       | Empty object | Additional incident fields merged into the payload, for example `{"caseorigincode": 1}`. |

### How it works

* The job requests an access token from Microsoft Entra for your tenant (client credentials flow, scope `<Organization URL>/.default`). If this fails, the job fails.
* It then sends one POST request to `<Organization URL>/api/data/v9.2/incidents`. One case is created for all assets, not one per asset.
* The case title is the workflow title. The description holds the workflow description, a line `Hostname Count: N`, a header line with the workflow's device columns, one comma separated row per device (list values joined with `|`), and the footer `Powered by OctoXLabs`.
* The customer is linked by **Customer Type** and **Customer ID**. **Priority** is sent as the case priority code only when you choose one.
* **Extra Parameters** is merged into the request body last, so a key you give there overrides a field the job set.
* The job does not check whether any asset matched. With no matched devices the case is still created, with `Hostname Count: 0`.
* If Dynamics answers with a status other than 200, 201 or 204, the job writes the status and response to the log, but the node does not fail and the workflow continues.
* The job passes on all assets it received, unchanged, through the **NEXT** edge.

### Example

```
Organization URL: https://org12345678.crm.dynamics.com
Tenant ID: YOUR_TENANT_ID
Client ID: YOUR_CLIENT_ID
Client Secret: YOUR_CLIENT_SECRET
Customer Type: account
Customer ID: 00000000-0000-0000-0000-000000000000
Priority: 2
Extra Parameters: {"caseorigincode": 1}
```

### What's next?

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>About Action Center</strong></td><td>Workflows, triggers, conditions and job nodes.</td><td><a href="broken://pages/bb2f624eb1c01048b9f65d24d1c066197ea76607">Broken link</a></td></tr><tr><td><strong>Action Center Settings</strong></td><td>Save defaults such as the Organization URL and Tenant ID.</td><td><a href="broken://pages/5accddd15304c1af96444dfc064130c453c9989d">Broken link</a></td></tr><tr><td><strong>Create Issue on Github</strong></td><td>Another job that opens a ticket with the matched assets.</td><td><a href="broken://pages/9030c7502b0aab5d65641af255f0c5e37476e786">Broken link</a></td></tr></tbody></table>
