Sync Dynamics 365 to SAP ERP System in near-real time using Microsoft Flow

Data Synchronization between CRM and ERP systems is essential for business. If the two business systems don’t offer default integration capabilities or if one is running on-premises and the other in the cloud, integration can be challenging, especially if you are not using best practices and the right tools.
In this blog Sync Dynamics 365 to SAP ERP System in near-real time using Microsoft Flow, I will describe a scenario, where a Dynamics 365 account is synchronized using Microsoft Flow in near-real time to SAP ERP on-premises, where an SAP customer is created and the customer number is written back to Dynamics 365 using the following tools:

  • Dynamics 365 as a CRM in the cloud
  • SAP ERP system on-premises
  • Microsoft Flow as workflow engine
  • SharePoint Online list for logging
  • ERPConnect Services Core (ECS Core) for SAP Integration in cloud scenariosThe following image shows the high-level architecture of the scenario.


Step 1: Customize your Dynamics 365 Account to provide related fields


In Dynamics 365 I have my accounts where I have created two fields to store the account type (prospect or customer) and the SAP customer number. When the account type changes from prospect to customer, the customer must be created in SAP. Any future changes should be updated in SAP.



Step 2: SharePoint Online list for logging


In SharePoint Online I created a list with the required account fields. This list will be used later in Flow to log all synchronized Dynamics 365 accounts including the SAP customer number.



Step 3: Install and configure ECS Core to connect to the SAP ERP system



ECS Core enables you to build powerful and sophisticated cloud integration for SAP on-premises. It allows you to integrate your cloud-based apps with SAP. For that, ECS Core uses only outbound connections. It pulls the pending requests from the cloud, sends the query to the SAP system for execution and then sends the SAP result back onto the cloud service.

ECS Core is installed on-premises. There I define the connection to the SAP ERP system. This connection will be used to connect to the SAP system and create or update the SAP customer.

The ECS Core connector for Microsoft Flow provides standard actions to manage SAP customers that will be used later in our scenario.


Step 4: Use Microsoft Flow to define a workflow to trigger account changes in Dynamics 365



As workflow engine, I am using Microsoft Flow to trigger any account changes in Dynamics 365, where the account type is changed from prospect to customer and no related SAP customer exists.


In this case, the SAP customer will be created using the Dynamics 365 account data. When the operation is successful, the Dynamics 365 account is updated with the SAP customer number. If the SAP customer exists, then it will be updated.


In Microsoft Flow, I will use the ECS Core custom connector to create and update SAP customers. We will use the action SAP Customer – Create to create an SAP Customer.


The action SAP Customer – Update will be used to update an existing SAP customer.

Below you find the Microsoft Flow branch to create the SAP customer. After the SAP customer is created, an item is created in the SharePoint list, the Dynamics 365 account is updated with the SAP customer number and an email notification is sent.


Optional steps:

In our workflow, we can use further optional steps. An additional Microsoft Flow step can be used, e.g. to be notified per email when a customer has been created or changed.


Now let us see this in action. Let us change the account type to customer. As you can see the SAP customer ID field is empty.


The workflow runs successfully.


Check that the customer has been created in SAP.

In the SharePoint list a new item has been created.


Go to Dynamics 365 and check that the SAP customer number is set.

In this blog, I have described how a Dynamics 365 account is synchronized in near-real time to SAP on- premises using Microsoft Flow as a workflow engine and ECS Core as SAP Integration tool. After the customer is created in SAP, the account in Dynamics 365 is updated with the SAP customer number.


Since Microsoft Flow offers connectors for other numerous Business Systems, including Salesforce for example, similar scenarios can be implemented. Theobald connector for SAP works also for Integration with other business systems and workflow engines on-premises and in the cloud.


External links:


Microsoft Flow:


ERPConnect Services Core (ECS Core) for SAP Integration: https://theobald-


Author: Khoder Elzein, SVP Presales & Product Management


Khoder is responsible for presales at Theobald Software and always has an attentive ear for business partners. When travelling in Germany or abroad, he provides customer support at PoCs, workshops and on training courses. He also looks after the product management & development. Khoder has been working in IT since the turn of the millennium; he has been a member of team Theobald since 2009 and enjoys working as speaker, blogger and trainer.


Tags: SAP Integration, Cloud Integration, Flow, Theobald, Dynamics 365, SharePoint Online

Share this on...