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

# Setup

> Connect to your Microsoft Dynamics CRM app for OAuth.

To setup your Microsoft Dynamics CRM app in Refold for OAuth, you will need the following credentials from your [Microsoft Azure account](https://azure.microsoft.com/en-gb/):

* Client ID
* Client Secret
* Scopes

### Pre-requisites

1. Microsoft Azure Account. You can create one [here](https://azure.microsoft.com/en-gb/).

<Info>If you haven't already created an app in Microsoft Azure, you'd need to create one.</Info>

### Creating an app in Microsoft Azure

To create a Microsoft Dynamics CRM app and acquire the above mentioned credentials, please follow the steps mentioned below:

1. Log in to your [Microsoft Azure account](https://azure.microsoft.com/en-gb/).
2. Search for **Microsoft Entra ID** and select it from **Services** in the top search bar.

<img height="200" src="https://mintcdn.com/cobalt-55/wOGvLSncBaYd4o6C/images/Ms365/ms365_navigation.png?fit=max&auto=format&n=wOGvLSncBaYd4o6C&q=85&s=15504278a7f8cda14af4d9d3c861b1df" alt="Navigation for App setup" data-path="images/Ms365/ms365_navigation.png" />

3. Navigate to `Overview` in the side menu > Click on `+Add` > Select `App Registration`.
4. Enter the App **Name** for your application and select `Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant)` under **Supported Account Types**.
5. Go to your [`Apps catalog`](https://app.gocobalt.io/apps) in **Refold** > Search for `Ms Dynamics CRM` > `Settings` > `Use your credentials` > `Callback Url` > Copy it.
6. Under the **Redirect URI** section, select **Platform** as `Web`, paste the **Callback Url** as the URL and click `Register`.

<img height="200" src="https://mintcdn.com/cobalt-55/wOGvLSncBaYd4o6C/images/Msdynamicscrm/msdynamics_register.png?fit=max&auto=format&n=wOGvLSncBaYd4o6C&q=85&s=6a969c9c7c5e30fae8d00c056193b269" alt="App Registration" data-path="images/Msdynamicscrm/msdynamics_register.png" />

<Info>
  If you already have an app created, then follows these steps to add Redirect URL:

  Select your Application > Select **Authentication** in side menu > Under **Platform configurations**, press the  **Add a platform** button > Select **Web** > Paste the Callback Url > Click on **Configure** > Click **Save** button at the bottom.
</Info>

7. Navigate to `Manage` > `API permissions` in the side menu > Click on `+ Add a permission`.
8. Choose the `Dynamics CRM` card under **Microsoft APIs** > Choose `Application permissions` > Select the **scopes** that you require > click on the `Add Permissions` button.

<img height="200" src="https://mintcdn.com/cobalt-55/wOGvLSncBaYd4o6C/images/Msdynamicscrm/msdynamics_config.png?fit=max&auto=format&n=wOGvLSncBaYd4o6C&q=85&s=6930d717895cbdb23ef864bd24b1878a" alt="Setting up Microsoft Dynamics CRM Developer app" data-path="images/Msdynamicscrm/msdynamics_config.png" />

9. Navigate to `Certificates and Secrets` in the side menu and under **Client Secrets** tab, press the `+ New client secret` button. Give a **Description**, select the best expiry for your application and click `Add` to create your credentials.
10. Copy the displayed **Client Secret** under the `Value` column.

<img height="200" src="https://mintcdn.com/cobalt-55/wOGvLSncBaYd4o6C/images/Msdynamicscrm/msdynamics_credentials.png?fit=max&auto=format&n=wOGvLSncBaYd4o6C&q=85&s=4621cd0e46587bbaa6caed7ea57e6586" alt="Getting Client Secret" data-path="images/Msdynamicscrm/msdynamics_credentials.png" />

11. Navigate to `Overview` in the side menu > `Essentials` tab > Copy the **Client ID** under `Application (client) ID`.

<img height="200" src="https://mintcdn.com/cobalt-55/wOGvLSncBaYd4o6C/images/Msdynamicscrm/msdynamics_id.png?fit=max&auto=format&n=wOGvLSncBaYd4o6C&q=85&s=2070a7e51c7524b0803e18325833f9b5" alt="Getting Client ID" data-path="images/Msdynamicscrm/msdynamics_id.png" />

#### Configuring credentials in Refold

App settings page lets you configure the authentication settings for an `OAuth 2.0` based application. For your customers to provide you authorization to access their data,
they would first need to install your application. This page lets you set up your application credentials.

<img height="200" src="https://mintcdn.com/cobalt-55/wOGvLSncBaYd4o6C/images/Msdynamicscrm/msdynamics_cobalt.png?fit=max&auto=format&n=wOGvLSncBaYd4o6C&q=85&s=14712d96eddbae013dd2e0cd9ef4970c" alt="Setting up application client credentials" data-path="images/Msdynamicscrm/msdynamics_cobalt.png" />

Provide the acquired Client ID and Client Secret under Settings of the app and save it.

#### Actions and triggers

Once the above setup is completed, you can create orchestrations of your use-cases using Microsoft Dynamics CRM actions and triggers. Following are the set of Microsoft Dynamics CRM actions and triggers
supported by Refold.

<Tabs>
  <Tab title="Actions">
    <AccordionGroup>
      <Accordion title="Lead">
        1. **Get Leads** - Get all leads in Microsoft Dynamics CRM.
        2. **Create Lead** - Create Lead in Microsoft Dynamics CRM.
        3. **Update Lead** - Update Lead in Microsoft Dynamics CRM.
        4. **Delete Lead** - Delete Lead in Microsoft Dynamics CRM.
      </Accordion>

      <Accordion title="Contact">
        5. **Get Contacts** - Get all contacts in Microsoft Dynamics CRM.
        6. **Create Contact** - Create Contact in Microsoft Dynamics CRM.
        7. **Update Contact** - Update Contact in Microsoft Dynamics CRM.
        8. **Delete Contact** - Delete Contact in Microsoft Dynamics CRM.
      </Accordion>

      <Accordion title="Opportunity">
        9. **Get Opportunities** - Get all opportunities in Microsoft Dynamics CRM.
        10. **Create Opportunity** - Create Opportunity in Microsoft Dynamics CRM.
        11. **Update Opportunity** - Update Opportunity in Microsoft Dynamics CRM.
        12. **Delete Opportunity** - Delete Opportunity in Microsoft Dynamics CRM.
      </Accordion>

      <Accordion title="Account">
        13. **Get Accounts** - Get all accounts in Microsoft Dynamics CRM.
        14. **Create Account** - Create Account in Microsoft Dynamics CRM.
        15. **Update Account** - Update Account in Microsoft Dynamics CRM.
        16. **Delete Account** - Delete Account in Microsoft Dynamics CRM.
      </Accordion>

      <Accordion title="Others">
        17. **HTTP Request** - Make HTTP API calls to any Microsoft Dynamics CRM documented REST APIs.
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Triggers">
    There are no triggers in this application.
  </Tab>
</Tabs>
