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

# Integrate with Microsoft Dynamics 365

> Get data from Microsoft Dynamics 365 Business Central, which is an enterprise resource planning (ERP) solution

## Before you begin

Prepare to connect to Microsoft

As part of the integration, you need to allowlist the Next Matter domain and create a service account. [See if you've completed all the required steps](/docs/integrate-with-microsoft).

## Get companies data from Business Central

If you want to keep making calls to Microsoft Dynamics Business Central, you can use the **Token template** to request an OAuth 2.0 access token from the Microsoft Entra ID. You can find the template in **Templates > 3rd party templates**.

1. In your Next Matter workflow, click **+ Add step** and select **Integration > Custom integration**.

2. Click **Settings** to configure the step.

3. Enter the following details:

   * **Method**: GET
   * **URL**: `https://api.businesscentral.dynamics.com/v2.0/DIRECTORY (TENANT) ID/production/api/v2.0/companies`

   Find the Tenant ID in the portal

   1. Go to [https://portal.azure.com](https://portal.azure.com) and sign in with your admin account.

   2. Navigate to the Microsoft Entra ID service from the left-hand side menu or search for it in the search bar.

   3. On the Entra ID overview page, you'll see your tenant information, including the Tenant ID (also referred to as the Directory ID). Alternatively, you can use [this link]() to open the overview page directly.

   * **Authentication**: Microsoft API token

4. Save your changes.

## Get opportunities

If you want to keep making calls to Microsoft Dynamics CRM, you can use the **CRM Token template** to request an OAuth 2.0 access token from the Microsoft Entra ID. You can find the template in **Templates > 3rd party templates**.

1. In your Next Matter process, click **+Add step** and select **Integration > Custom integration**.

2. Click **Settings** to configure the step.

3. Enter the following details:

   * **Method**: GET
   * **URL**: `YOUR_DYNAMICS_URL/api/data/v9.0/opportunities` (or if you used the Token template as the first step, use the URI variable from the previous step).
   * **Authentication**: Microsoft API token (or if you used the Token template as the first step, use the token variable from the previous step).

4. Create the variables for the email address (value: `$.value[*].emailaddress`), description (`$.value[*].description`), and name (`$.value[*].name`).

5. Save your changes.
