I need to implement a bi-directional communication between Microsoft Dynamics CRM and a 3rd party server. The ideal scenario is as follows:
- User tries to create an entity in CRM
- In pre-create hook a 3rd party library function is calle开发者_运维百科d (or web service or whatever), filled with relevant info, which tries to create the respective entity on the server
- If the call fails, creation fails in CRM
- If the call succeeds, the entity is created in the CRM AND additional fields are filled with return values from the call
More specifically, I want to do something like this when user tries to create a new entity instance:
try {
ExternalWebService.CreateTrade(ref TradeInfo info)
//this was initialized on the external server
myCRM_Trade_Entity.SerialNo = info.SerialNo;
CreateNew(myCRM_Trade_Entity);
} catch (whatever) {
fail;
}
What would be the suggested way to do this? I am new to Dynamics, have read about Workflows and Plugins but am not sure how should I do this properly.
The way to do that is obviously a plugin, except if the process called by the web service is very long and could timeout.
The only way to avoid creating an entity, is to create a plugin and hook it on the pre-create event, like you are saying.
When using a workflow, the entity must be saved before the workflow is executed.
I think you are on the good way. I would, however, avoid including a library, the webservice solution should be better, because it does not required to register other libraries before registering the plugin assembly.
精彩评论