Manage Dynamics 365 records with Azure Logic Apps
With Azure Logic Apps and the Dynamics 365 connector, you can create automated tasks and workflows based on your records in Dynamics 365. Your workflows can create records, update items, return records, and more in your Dynamics 365 account. You can include actions in your logic apps that get responses from Dynamics 365 and make the output available for other actions. For example, when an item is updated in Dynamics 365, you can send an email using Office 365.
This article shows how you can build a logic app that creates a task in Dynamics 365 whenever a new lead record is created in Dynamics 365. If you're new to logic apps, review What is Azure Logic Apps?.
An Azure subscription. If you don't have an Azure subscription, sign up for a free Azure account.
Basic knowledge about how to create logic apps
The logic app where you want to access your Dynamics 365 account. To start your logic app with a Dynamics 365 trigger, you need a blank logic app.
Add Dynamics 365 trigger
When you use a trigger or action that accesses a service for the first time, the Logic Apps Designer prompts you to create a connection to that service. You can then provide the necessary connection information directly from your logic app inside the designer.
First, add a Dynamics 365 trigger that fires when a new lead record appears in Dynamics 365.
In the Azure portal, open your blank logic app in Logic App Designer, if not open already.
In the search box, enter "Dynamics 365" as your filter. For this example, under the triggers list, select this trigger: When a record is created
If you're prompted to sign in to Dynamics 365, sign in now.
Provide these trigger details:
Property Required Description Organization Name Yes The name for your organization's Dynamics 365 instance to monitor, for example, "Contoso" Entity Name Yes The name for the entity to monitor, for example, "Leads" Frequency Yes The unit of time to use with intervals when checking for updates related to the trigger Interval Yes The number of seconds, minutes, hours, days, weeks, or months that pass before the next check
Add Dynamics 365 action
Now add the Dynamics 365 action that creates a task record for the new lead record.
Under your trigger, choose New step.
In the search box, enter "Dynamics 365" as your filter. From the actions list, select this action: Create a new record
Provide these action details:
Property Required Description Organization Name Yes The Dynamics 365 instance where you want to create the record, which doesn't have to be the same instance in your trigger, but is "Contoso" in this example Entity Name Yes The entity where you want to create the record, for example, "Tasks"
When the Subject box appears in your action, click inside the Subject box so the dynamic content list appears. From this list, select the field values to include in the task record associated with the new lead record:
Field Description Last name The last name from the lead as the primary contact in the record Topic The descriptive name for the lead in the record
On the designer toolbar, choose Save for your logic app.
To manually start the logic app, on the designer toolbar, choose Run.
Now create a lead record in Dynamics 365 so you can trigger your logic app's workflow.
Add filter or query
To specify how to filter data in a Dynamics 365 action, choose Show advanced options in that action. You can then add a filter or order by query. For example, you can use a filter query to get only the active accounts and order those records by account name. For this task, follow these steps:
Under Filter query, enter this OData filter query:
statuscode eq 1
Under Order By, when the dynamic content list appears, select Account Name.
For more information, see these Dynamics 365 Customer Engagement Web API system query options:
Best practices for advanced options
When you specify a value for a field in an action or trigger, the value's data type must match the field type whether you manually enter the value or select the value from the dynamic content list.
This table describes some of field types and the required data types for their values.
|Field type||Required data type||Description|
|Text fields||Single line of text||These fields require a single line of text or dynamic content that has the text type.
Example fields: Description and Category
|Integer fields||Whole number||Some fields require integer or dynamic content that has the integer type.
Example fields: Percent Complete and Duration
|Date fields||Date and Time||Some fields require a date with mm/dd/yyyy format or dynamic content that has the date type.
Example fields: Created On, Start Date, Actual Start, Actual End, and Due Date
|Fields requiring both a record ID and lookup type||Primary key||Some fields that reference another entity record require both a record ID and a lookup type.|
Expanding on these field types, here are example fields in Dynamics 365 triggers and actions that require both a record ID and the lookup type. This requirement means values that you select from the dynamic list won't work.
|Owner||Must be either a valid user ID or team record ID.|
|Owner Type||Must be either
|Regarding||Must be a valid record ID, such as an account ID or contact record ID.|
|Regarding Type||Must be a lookup type, such as
|Customer||Must be a valid record ID, such as an account ID or contact record ID.|
|Customer Type||Must be the lookup type, such as
In this example, the action named Create a new record creates a new task record:
This action assigns the task record to a specific user ID or team record ID, based on the record ID in the Owner field and the lookup type in the Owner Type field:
This action also adds an account record that's associated with the record ID added in the Regarding field and the lookup type in the Regarding Type field:
Find record ID
To find a record ID, follow these steps:
In Dynamics 365, open a record, such as an account record.
On the actions toolbar, choose one of these steps:
- Choose Pop Out.
- Choose EMAIL A LINK so you can copy the full URL into your default email program.
The record ID appears in the URL between the
Troubleshoot failed runs
To find and review failed steps in your logic app, you can view your logic app's runs history, status, inputs, outputs, and so on.
In the Azure portal, on your logic app's main menu, select Overview. In the Runs history section, which shows all the run statuses for your logic app, select a failed run for more information.
Expand a failed step so you can view more details.
Review the step's details, such as the inputs and outputs, which can help you find the cause behind the failure.
For more information about troubleshooting logic apps, see Diagnosing logic app failures.
For technical details, such as triggers, actions, and limits, as described by the connector's OpenAPI (formerly Swagger) file, see the connector's reference page.
- Learn about other Logic Apps connectors