Handling large-scale data tasks in Dynamics 365 CRM can be challenging, especially when syncing thousands of records with external systems. Background Operations allow these resource-intensive tasks to run asynchronously, keeping the system responsive.
In this article, we’ll walk through the technical setup using a practical scenario: syncing thousands of records with an external system. You’ll learn how to create a Background Operation and use a Callback URL to get notified or trigger other processes automatically once the job completes.
For insights into synchronous vs asynchronous workflows and why Background Operations are essential for large data sets, refer to Part 1.
The Scenario: Syncing Records with External System
Many organizations use both Dynamics 365 CRM and an external ERP system, requiring regular synchronization of all customer and order data. This includes not only the records themselves but also related data in the external system.
Using a Background Operation allows this process to run asynchronously, without affecting other running processes. It also supports a Callback URL, which notifies the administrator automatically once the operation is completed, eliminating the need for manual monitoring.
With a Background Operation, all syncing logic can be consolidated into a single request, allowing Dynamics 365 to run the large job in the background without disturbing users, while automatically informing the system or administrators when the task is finished.
Technical Setup: Running Background Operations Asynchronously
To implement this in Dynamics 365, a Custom API containing the sync logic must be created and triggered via the ExecuteBackgroundOperation request.
Step 1: Create a Custom API
Create a Custom API in Dynamics 365 called SyncRecordsToExternalSystem. Back it with a plugin, which handles:
- Querying Dynamics 365 records
- Sending data to the external system via API
- Handling responses and updating sync status flags
This plugin runs in the background, removing timeout limitations and efficiently processing thousands of records...Read More>>