I am working on an Enterprise Service Bus project where one of the systems from which we pull data in Dynamics CRM Online.
We are wondering which approach is better - pulling data from CRM with custom jobs on a regular basis (say 2 hours) or sending the data using a CRM Plugin calling our APIs (on demand). So where can I find the limitations for these two approaches in the context of CRM Online?
In the context of CRM Plugin (on demand approach):
- Can an external API service be called from a CRM Plugin? Are there any requirements for the API service, in order for it to be called successfully? Can a CRM Plugin connect to an MS SQL DB Server and write date in some tables directly?
In the context of custom jobs using CRM services (periodic calls):
- Are there any limitations when calling a CRM Online REST service? What are the requirements for the API service, in order for it to call the CRM services successfully?
Thank you in advance,
You can call external API from Plugin but I suggest to go for custom workflow activity as rest call are Async.
You can not call Database from Plugin or workflow.
If the Data Sync is one way, pushing from Plugin calling external API is better for the following reason
01. The update is almost real-time
02. There wont be any batch process so no single point of failure
03. Based on my experience with scheduled tasks, on-demand is always better if its possible.
One negative side to directly calling the API from plugin is that it may hold-up the UI if its Sync plugin and that will affect the user experience and performance.
I had similar experience and here is what I did to solve the problem
01. I created an entity in CRM to queue all the updates - In your case, you could call this intermediate entity as -> ESB Queue or something along the line
02. I then created a workflow that triggers on Create on this queue entity.
03. In the Workflow I used a Custom Workflow Activity (CWA) I created to communicate to external API.
Your plugin will just created a queue record in the custom queue entity mentioned above and the workflow will trigger asynchronously and push that via API
Can an external API service be called from a CRM Plugin? Yes you can call from Plugin or CWA
Are there any requirements for the API service, in order for it to be called successfully? REST API is preferred over WCF or ASMX. As long as you create your API to be RESTful, no special requirement to call this from Plugin or CWA. One thing to note, you cant use any third party libraries in the plugin or CWA as the ILMerge is not supported by CRM Online anymore.
Can a CRM Plugin connect to an MS SQL DB Server and write date in some tables directly? No CRM Online cannot connect to MS SQL Database directly. You could have the DB connection in your API and let CRM call your API to perform any operation or Create an Azure function that can talk to DB and call the function from Plugin.
About API Limit : If you call CRM API over 4000 times within 5 minutes, you may get error, please refer to the following
Business Applications communities