Create and manage records in Common Data Service (Microsoft Dataverse) by using Azure Logic Apps

Note

In November 2020, Mutual Information Service was renamed to Microsoft Dataverse.

With Azure Logic Apps and the Common Data Service connector, you tin can build automated workflows that manage records in your Common Data Service, now Microsoft Dataverse database. These workflows tin can create records, update records, and perform other operations. Yous can besides become information from your Dataverse database and make the output available for other deportment to apply in your logic app. For case, when a record is updated in your Dataverse database, yous can send an email by using the Office 365 Outlook connector.

This commodity shows how you tin build a logic app that creates a job record whenever a new lead record is created.

Prerequisites

  • An Azure account and subscription. If y'all don't have an Azure subscription, sign up for a free Azure business relationship.

  • A Common Data Service environment, which is a space where your arrangement stores, manages, and shares business data and a Mutual Information Service database. For more than information, see these resource:

    • Acquire: Get started with Common Data Service
    • Ability Platform - Environments overview
  • Basic noesis nearly how to create logic apps and the logic app from where you desire to access the records in your Dataverse database. To start your logic app with a Mutual Data Service trigger, you need a blank logic app. If you lot're new to Azure Logic Apps, review Quickstart: Create your first workflow by using Azure Logic Apps.

Add Common Information Service trigger

When you add a trigger or action that connects to a service or arrangement, and yous don't take an existing or active connection, Azure Logic Apps prompts you to provide the connection information, which varies based on the connection type, for example:

  • A name to use for the connectedness
  • Your account credentials
  • The server or organization name
  • A connexion cord
  • The authentication type to apply

For this example, add the Common Data Service trigger that fires when a new record is created.

  1. In the Azure portal, open up your blank logic app in Logic App Designer, if not open already.

  2. In the search box, enter mutual data service. For this example, under the triggers list, select this trigger: When a tape is created

    Select "When a record is created" trigger

  3. If prompted, sign in to the Common Data Service.

  4. In the trigger, provide information about the surround where you desire to monitor for new "Leads" records, for example:

    Trigger information for environment to monitor

    Holding Required Description
    Environs Aye The environment to monitor, for example, "Fabrikam Sales Production". For more information, see Power Platform - Environments overview.
    Entity Name Yes The entity to monitor, for example, "Leads"
    Scope Yes The source that created the new record, for example, a user in your business organization unit or whatsoever user in your organization. This instance uses "Business unit".

Add Common Data Service action

Now add a Common Data Service action that creates a task record for a new "Leads" record.

  1. Under the When a tape is created trigger, select New step.

  2. In the search box, enter common data service. From the deportment listing, select this action: Create a new record

    Select "Create a new record" action

  3. In the action, provide the information near the environment where you want to create the new task record. If available, other properties as well announced based on the entity that you lot selected for this activeness, for example:

    Action information for the environment where to create the record

    Belongings Required Description
    Organization Name Aye The environment where you want to create the record, which doesn't have to be the same surround in your trigger, but is "Fabrikam Sales Production" in this example
    Entity Name Yeah The entity where you want to create the record, for example, "Tasks"
    Subject area Yes, based on the entity selected in this example A short description almost the objective for this chore
    1. For the Subject property, enter this text with a trailing space:

      Follow up with new lead:

    2. Go on your arrow inside the Subject box and so that dynamic content list stays visible.

    3. In the list, from the When a tape is created section, select the trigger outputs that yous want to include in the chore tape, for example:

      Select trigger outputs to use in task record

      Trigger output Description
      Outset Proper noun The beginning proper noun from the atomic number 82 record to apply as the primary contact in the task record
      Last Proper noun The concluding name from the lead record to use equally the chief contact in the task tape
      Description Other outputs to include in the task tape, such as electronic mail accost and business concern phone number

    When you're done, the activeness might look like this example:

    Finished "Create a new record" action

  4. Salvage your logic app. On the designer toolbar, select Salve.

  5. To manually first the logic app, on the designer toolbar, select Run. To test your logic app, create a new "Leads" record.

Trigger simply on updated attributes

For triggers that run when records are updated, such as the When a record is updated action, you lot can use filter attributes so that your logic app runs merely when the specified attributes are updated. This capability helps you prevent unnecessary logic app runs.

  1. In the trigger, from the Add together new parameter listing, select Attribute Filters.

    Screenshot that shows the "When a record is updated" action and the opened "Add new parameter" list with the "Attribute Filters" property selected.

  2. For each Attribute Filters Item, select the attribute that you want to monitor for updates, for example:

    Add "Attribute Filters" property

List records based on a filter

For actions that return records, such as the List records activity, you can use an ODATA query that returns records based on the specified filter. For example, yous have the activity list only the records for active accounts.

  1. In the action, open the Add new parameter list, and select the Filter Query property.

    Add "Filter Query" property

  2. In the Filter Query belongings that now appears in the action, enter this ODATA filter query: statuscode eq i

    Enter ODATA filter query for filtering records

For more data virtually $filter organisation query options, run into Common Data Service - Filter results.

List records based on an order

For actions that render records, such as the List records action, you can use an ODATA query that returns records in a specified order, which varies based on the records that the action returns. For example, yous can have the action list the records based on the business relationship name.

  1. In the action, open up the Add new parameter list, and select the Order Past property.

    Add "Order by" property

  2. In the Order By property that now appears in the activity, enter this ODATA filter query: name

    Enter ODATA filter query for ordering records

For more information about $orderby system query options, see Common Data Service - Guild results.

Field information types

Regardless whether yous manually enter a value or select a value from the dynamic content listing for a field in a trigger or action, the value'due south information type must match the field's required data blazon.

This table describes some field types and the data types that those fields require for their values.

Field Data type Description
Text field Unmarried line of text Requires either a unmarried line of text or dynamic content that has the text data blazon, for example, these properties:

- Description
- Category

Integer field Whole number Requires either an integer or dynamic content that has the integer data type, for example, these backdrop:

- Percent Complete
- Elapsing

Date field Date and Time Requires either a engagement in MM/DD/YYY format or dynamic content that has the appointment data type, for example, these properties:

- Created On
- Starting time Date
- Actual Start
- Actual Cease
- Due Engagement

Field that references another entity record Primary central Requires both a record ID, such every bit a GUID, and a lookup type, which means that values from the dynamic content list won't piece of work, for instance, these properties:

- Possessor: Must be a valid user ID or a team record ID.
- Possessor Type: Must be a lookup blazon such as systemusers or teams, respectively.

- Regarding: Must be a valid tape ID such as an account ID or a contact record ID.
- Regarding Type: Must be a lookup blazon such as accounts or contacts, respectively.

- Customer: Must exist a valid record ID such every bit an account ID or contact record ID.
- Client Type: Must be the lookup type, such as accounts or contacts, respectively.

This case shows how the Create a new record activity creates a new "Tasks" tape that'due south associated with other entity records, specifically a user record and an account record. The action specifies the IDs and lookup types for those entity records by using values that match the expected data types for the relevant backdrop.

  • Based on the Owner property, which specifies a user ID, and the Owner Type property, which specifies the systemusers lookup type, the action assembly the new "Tasks" record with a specific user.

  • Based on the Regarding property, which specifies a record ID, and the Regarding Blazon property, which specifies the accounts lookup blazon, the activity associates the new "Tasks" record with a specific account.

Create "Tasks" record associated with IDs and lookup types

Connector reference

For technical information based on the connector'due south Swagger description, such as triggers, actions, limits, and other details, run across the connector'southward reference page.

Troubleshooting problems

Calls from multiple environments

Both connectors, Mutual Data Service and Common Information Service (current surround), store information about the logic app workflows that demand and get notifications well-nigh entity changes past using the callbackregistrations entity in your Microsoft Dataverse. If you copy a Dataverse organization, whatever webhooks are copied too. If y'all copy your system before y'all disable workflows that are mapped to your arrangement, any copied webhooks too point at the aforementioned logic apps, which then get notifications from multiple organizations.

To stop unwanted notifications, delete the callback registration from the system that sends those notifications by following these steps:

  1. Identify the Dataverse system from where you want to remove notifications, and sign in to that organization.

  2. In the Chrome browser, discover the callback registration that you want to delete by following these steps:

    1. Review the generic list for all the callback registrations at the following OData URI so that y'all can view the data within the callbackregistrations entity:

      https://{organization-name}.crm{example-number}.dynamics.com/api/data/v9.0/callbackregistrations:

      Note

      If no values are returned, you might non have permissions to view this entity type, or you might not exist signed in to the correct organization.

    2. Filter on the triggering entity's logical proper name entityname and the notification event that matches your logic app workflow (message). Each upshot type is mapped to the message integer as follows:

      Effect blazon Message integer
      Create 1
      Delete 2
      Update 3
      CreateOrUpdate 4
      CreateOrDelete five
      UpdateOrDelete half dozen
      CreateOrUpdateOrDelete 7

      This example shows how you tin can filter for Create notifications on an entity named nov_validation by using the following OData URI for a sample organisation:

      https://fabrikam-preprod.crm1.dynamics.com/api/information/v9.0/callbackregistrations?$filter=entityname eq 'nov_validation' and message eq 1

      Screenshot that shows browser window and OData URI in the address bar.

      Tip

      If multiple triggers exist for the aforementioned entity or result, y'all can filter the listing by using boosted filters such equally the createdon and _owninguser_value attributes. The owner user'south proper noun appears under /api/data/v9.0/systemusers({id}).

    3. After you find the ID for the callback registration that you desire to delete, follow these steps:

      1. In your Chrome browser, open the Chrome Programmer Tools (Keyboard: F12).

      2. In the window, at the top, select the Console tab.

      3. On the command-line prompt, enter this command, which sends a asking to delete the specified callback registration:

        fetch('http://{organization-proper noun}.crm{instance-number}.dynamics.com/api/data/v9.0/callbackregistrations({ID-to-delete})', { method: 'DELETE'})

        Important

        Make sure that you make the request from a not-Unified Customer Interface (UCI) folio, for example, from the OData or API response page itself. Otherwise, logic in the app.js file might interfere with this performance.

    4. To confirm that the callback registration no longer exists, check the callback registrations list.

Next steps

  • Larn most other connectors for Azure Logic Apps