activities
latest
false
UiPath logo, featuring letters U and I in white
Classic Integrations Activities
Last updated Nov 8, 2024

Quickstart - Records

Overview

The purpose of this guide is to help you create a working sample that uses the following Microsoft Dynamics 365 activities:

This working sample enables you to quickly verify the connection to your Microsoft Dynamics 365 application and get familiar with the activity's input/output datatypes.

After completing the steps in this guide, you'll have an automation sequence that does the following:

  1. Establishes a connection to your Microsoft Dynamics 365 application (Get Credential and Microsoft Dynamics Application Scope).
  2. Inserts a new account record (Insert Record).
  3. Searches for the inserted account record (Search Records).
  4. Updates the website field of the account record (Update Record).
  5. Verifies the account record was successfully updated (Get Record).
  6. Deletes the inserted account record (Delete Record).

    Note: While there may be more efficient ways of achieving the same result, the goal of this sequence is to demonstrate all of the record activities.

Prerequisites

Before you begin:

  1. Complete the Microsoft Dynamics 365 Setup steps.
  2. Use the Package Manager to install the Microsoft.Activities.Extensions package (this is for the Search Records activity).

    Note: This guide uses ClientCredentials as the AuthenticationType in the Microsoft Dynamics Application Scope activity. If you prefer to use PasswordCredentials, you can skip step 1 (add a Get Credential activity) and follow the bulleted substeps in step 2 (add the Microsoft Dynamics Application Scope activity).

Steps

Build your project
  1. Add a Get Credential activity.
  2. Enter the AssetName for the credential asset you created (during the Setup) for the application Client Secret (e.g., "MicrosoftDynamics365ClientCredentials").
  3. Create and enter a SecureString variable for the Password property (e.g., clientSecret).
  4. Create and enter a String variable for the Username property (e.g, clientId).
  5. Add the Microsoft Dynamics 365 Application Scope activity after the Get Credential activity.
  6. Click the Configure button (this opens the Connection Wizard), select your AuthenticationType, enter your credentials, and click the Test Connection button. For more information about the purpose and behavior of this wizard, see the section.

    • This step is for design time purposes only. To populate the Microsoft Dynamics Application Scope properties, continue to complete the steps below.
  7. In the AuthenticationType property, select your preferred authentication type.

    • If you select PasswordCredentials, create a String variable for the ClientId (e.g., Name: clientId Default: "56X9aXXX-b5d9-4a90-XXXX-13XX9643XXXX")
  8. In the ClientId property, enter the String variable you created for the Get Credential activity or substep above (e.g., clientId).
  9. In the ClientSecret property, enter the SecureString variable you created for the Get Credential activity (e.g., clientSecret).
    • If you selected PasswordCredentials leave the ClientSecret property empty.
  10. In the EndpointUrl property, create and enter a String variable with the URL of the CRM instance that you want to connect to (e.g., Name: endpointURL Default: "https://uipath.crm4.dynamics.com/" )
  11. In the TenantId property, create and enter a String variable for the directory (tenant) ID assigned to your Azure Active Directory (ADD) tenant (e.g., Name: tenantId Default: "d8353d2a-b153-4d17-8827-902cXXXXXXX").
    • If you selected PasswordCredentials, select your password Prompt preference (options).



  12. Add the Insert Record activity inside the Microsoft Dynamics Application Scope activity.

    1. Click the Configure button inside the Insert Record activity (this opens the Object Wizard).

      1. In the Select Entity drop-down list, select Account.
      2. In the accountId field, create and enter a String variable (e.g., accountId).
      3. In the Add Single Field textbox, enter name and click enter.
      4. In the name field, enter an account name (e.g., "Quickstart_Account").
      5. Click the Done button.



    2. Add an Add to dictionary activity after the Insert Record activity.
    3. In the Dictionary property, create and enter a Dictionary<String,String> variable accordingly: Name: queryOption, Default: new Dictionary(Of String, String) (you may use a different Name value, but the Default value is required).
    4. In the Key property, enter "$filter".
    5. In the Value property, enter "name eq 'Quickstart_Account'" (Quickstart_Account is the name of the account you inserted in the steps above. If you entered a different name, use that value instead).

      • For more information about query values, see the query metadata and/or query data pages in the Microsoft documentation.
    6. Add the Search Records activity after the Add to dictionary activity.
    7. In the Object property, select Account.
    8. In the Query Options property, enter the Dictionary<String,String> variable you created above (e.g., queryOption).
    9. In the Result property, create and enter a DataTable variable (e.g., searchResults).


  13. Add an Assign activity after the Search Records activity.

    1. In the To property, create and enter a String variable (e.g., webURL).
    2. In the Value property, enter the following: searchResults.Rows(0).Item("websiteurl").ToString.

    3. Add an If activty after the Assign activity.
    4. Create a String variable with a default value of a URL (e.g., Name: website, Default: "www.uipath.com").
    5. In the Condition property, enter the following: webURL = website.
    6. In the Then statement box, add a Write Line activity with the following Text: "Website present".
    7. In the Else statement box, add the Update Record activity.

      1. Click the Configure button inside the Update Record activity (this opens the Object Wizard).

        1. In the Select Entity drop-down list, select Account.
        2. In the accountId field, enter the String variable you created for the Insert Record activity (e.g., accountId).
        3. In the Add Single Field textbox, enter websiteurl and click enter.
        4. In the name field, enter the String variable you created in the step above (e.g., website).
        5. Click the Done button.



Test your project
  1. Add the Get Record after the Update Record activity (inside the Else statement box).

    1. Click the Configure button inside the Get Record activity (this opens the Object Wizard).

      1. In the Select Entity drop-down list, select Account.
      2. In the accountId field, enter the String variable you created for the Insert Record activity (e.g., accountId).
      3. In the Add Single Field textbox, enter websiteurl and click enter.
      4. In the websiteurl field, create and enter a String variable (e.g., websiteVerification).
      5. Click the Done button.
    2. Add an If activity after the Get Record activity (inside the Else statement box).
    3. In the Condition property, enter the following: website = websiteVerification.
    4. In the Then statement box, add a Write Line activity with the following Text: "Website update succeeded!".
    5. In the Then statement box, add a Write Line activity with the following Text: "Website update failed".
  2. Add the Delete Record activity outside of the first If activity.

    1. In the Object property, select Account.
    2. In the Id field, enter the String variable you created for the Insert Record activity (e.g., accountId).
    3. In the MicrosoftDynamicsStatus property, create and enter a ResponseStatus variable (e.g., responseStatus).
  3. Add a Write Line activity after the Delete Record activity.

    1. In the Text property, enter the following: "Record deleted: "+responseStatus.Success.ToString.
  4. Click Run and verify the Output window includes the expected write line values.



You're done!

To learn more about the Microsoft Dynamics 365 activities (including example property inputs/outputs), see the Activities page for a complete activity list and links to the activity detail pages.

  • Overview
  • Prerequisites
  • Steps

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.