# Setup

> Set up the Microsoft Dynamics 365 Activities package, including prerequisites, package installation, and authentication

## Introduction

To successfully establish a connection and send requests to the Web API, the [Microsoft Dynamics Application Scope](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-scope) activity must complete authentication using the [OAuth 2.0](https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/authenticate-oauth) protocol.

To give the **Microsoft Dynamics 365 Scope** activity the ability to authenticate using OAuth 2.0 and to enable the other activities to successfully send requests to the Web API, you must complete the following steps:

1. [Register your application](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-setup#setup).
2. [Create client secret](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-setup#setup).
3. [Create Credential Asset](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-setup#setup).
4. [Build your project](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-setup#setup).

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-178556-a7d1ce8a-6de25aff.webp)

   :::note
   The Microsoft Dynamics 365 activities have a dependency on the [Common Data Service])(https://docs.microsoft.com/en-us/dynamics365/human-resources/hr-admin-integration-choose-technology#common-data-service-entities). Because of this dependency, the activities primarily support **Customer Engagement** solutions. Currently, Microsoft Dynamics for **Finance & Operations** is **not supported**.
   :::

## Steps

### 1. Register your application

Follow the Common Data Service specific instructions in the Microsoft documentation to [create an application registration](https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/walkthrough-register-app-azure-active-directory#create-an-application-registration) (these steps include assigning the appropriate API permissions).

For more information about app registration for the Common Data Service, see [Use OAuth with Common Data Service](https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/authenticate-oauth) in the Microsoft documentation.

When registering your application, take note of the **Application (client) ID** and **Directory (tenant) ID** values; you'll enter these in the **Microsoft Dynamics Application Scope** activity.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-183513-cf28d8d6-31b2fa8d.webp)

### 2. Create client secret

:::note
This step is only applicable if you plan to use *ClientCredentials* as the **AuthenticationType** in the activity. If you plan to use *PasswordCredentials*, you can proceed to [Build your project](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-setup#setup).
:::

Follow the instructions in the Microsoft documentation to configure your registered application to [connect as an app](https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/authenticate-oauth#connect-as-an-app) (i.e. connect using a client secret). For more information about client secrets, see [Use Client Secrets & Certificates](https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/authenticate-oauth#use-client-secrets--certificates) in the Microsoft documentation.

For quick reference, the image below shows how we created our client secret for our example projects.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-180244-f8226572-50c87579.webp)

### 3. Create Application User

Log in to your Microsoft Dynamics 365 Customer Engagement account. Go to **Settings > Security > Users > New User**.

Change the view to Application User. Enter the *Application ID* from the previous step in the *Application ID* field.

Complete the other fields such as (**Full Name**) and (**Primary Email**) and then save the user.

   ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/legacy-integrations-docs-image-178572-8b53254f-e9c1dab4.webp)

### 4. Create Credential Asset

:::note
This step is only applicable if you plan to use *ClientCredentials* as the **AuthenticationType** in the [Microsoft Dynamics Application Scope](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-scope) activity. If you plan to use *PasswordCredentials*, you can proceed to [Build your project](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-setup#setup).
:::

The **Microsoft Dynamics Application Scope** activity requires a `SecureString` input for the **ClientSecret** property. To enter the `SecureString` variable, it's recommended that you follow the suggestions and steps in the section of this guide.

### 5. Build your project

1. Create a new automation project.
   1. Open **UiPath Studio**.
   2. Under **New Project**, click **Process** (this opens a **New Blank Process** window).
   3. Enter a project **Name**, **Location**, and **Description**.
   4. Click **Create**.
2. Install the **UiPath.MicrosoftDynamics.Activities** package.
   1. In the **Design** ribbon, click **Manage Packages** (this opens the **Manage Packages** window).
   2. Under **All Packages**, click **Official!**
   3. In the **Search** bar, enter *Dynamics*.
   4. Click, install and accept the license for the **UiPath.MicrosoftDynamics.Activities**.
      * For more information about Uipath Studio packages, see [Managing Packages](https://docs.uipath.com/studio/docs/managing-activities-packages) in the Studio Guide.

You're done!

Now that you have completed the setup, you can start adding the Microsoft Dynamics 365 activities to your project.

## Next steps

For a hands-on learning experience and to quickly start using the activities, see the [Quickstart](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-quickstarts) guide. This guide provides step-by-step instructions to help you create a working sample of the different activities so that you can verify the connection to your Microsoft Dynamics 365 instance and get familiar with the input/output properties.

To learn more about the Microsoft Dynamics 365 activities (including example property inputs/outputs), see the [Activities](https://docs.uipath.com/activities/other/latest/legacy-integrations/microsoft-dynamics-365-activities) page for a complete activity list and links to the activity detail pages.
