Update Dynamics 365 Data Using Flow

This article is about updating Dynamics 365 data using Microsoft Flow.

Introduction

In our earlier article, we discussed how we can create data in Dynamics 365 CE using Microsoft Flow from an Excel file. Now, in this article, we are going to discuss how we can update existing data using flow.

Requirement

In our earlier example, we used the following Excel table to upload the data to the contact entity.

upload data to contact entity

Now, let’s say we have updated some data and added some new records. Now, we want to update the existing data based on the email id of contact and if it’s not available, we want to create it (like upsert operation).

records

Solution

Follow my earlier article and implement steps 1-4 to achieve the following.

upload data to contact entity 

Now, let's add a List Records action from Dynamics 365 and configure it like the following. Here, we are going to query the Dynamics 365 contacts based on the email id from the Excel file.

email id from excel file 

We need to add a condition to check if the list of records is not empty. For that, first, add a condition and set the value like below.

add a condition 

After that, click on Edit in advance mode and change it like below. Here, we are checking if the above list record action has returned a null value or not.

null value 

Now, after checking the above condition, we need to add the "Create" step under "Yes" section and "Update" step under "No" section. Look in the below image for details.

Update section 

We need to configure the update section like this.

configure update

We can set other fields using expression items(‘Apply_to_each’)[‘ColumnNameFromExcelFile’] . Finally, add the "Delete" step to delete the Excel file from One Drive.

add delete 

Now, save your changes and upload the file to One Drive. After a couple of minutes, we will be able to see the contact data on screen.

contact data 

If a contact exists already with the same email id, it will get updated; otherwise, it will create a new contact record.

Stay tuned for more Dynamics 365 Contents!!