Virtual Entities for pulling in CRM data from other instances

A new feature in Dynamics is the concept of Virtual Entities.  This allows an entity to be created in Dynamics  where its data is not actually stored in Dynamics.  Its read only at the moment, but it allows you to pull in data from any ODATA data source, and display it in Dynamics as if it were part of the system, and that includes displaying data in quick view forms, grids, advanced find etc.

Now, one of the issues I have come across within my CRM experience is a requirement to pull in data from one CRM environment, into another.  This has generally involved data migration, or some sort of costly integrations.  So, with this new feature, I wondered if it would help solve this issue.

Well, it does and it doesn’t.  When trying to use Virtual Entities to pull in data from one CRM environment to another, I discovered a pretty big flaw, and that is authentication.  From one CRM environment, trying to get it to authenticate with another environment while querying the ODATA endpoint is tricky, or even impossible.  I didn’t spend too much time on trying to solve this, I just assumed it was a no go, so to be able to test Virtual Entities, I decided to throw all security concerns out the window, and come up with a simple test solution.

So, my plan was this :

  • Create my own ODATA web service
  • Connect to a CRM instance that contains the data using a specific user account
  • Pull out the CRM data, and present it in an unauthenticated ODATA endpoint.

Yes, yes, I realize that’s a bit scary (exposing CRM data without any kind of authentication), but this was just a test.  So, I now have an endpoint that proxies queries against the Contact entity.  So, the following URLS should return data from my CRM test environment, without requiring any username.

http://crmproxydata.azurewebsites.net/Contacts

http://crmproxydata.azurewebsites.net/Contacts?$filter=contains(Name,’Spencer’)

So, now that I have that very basic web service, I can now configure my new Dynamics 365 version 9.0 environment with an ODATA data source.

So, from the Settings, administration page, I can do the following :

And configure it like so:

And in my test solution, I create a new Entity and mark it as a Virtual Entity.

And configure the appropriate fields to match the information my web service is returning:

Now, if I do an Advanced Find in the CRM that does not contain any Contacts, but instead choose my new External Contacts, it shows the information from a completely different CRM environment.

And clicking on one of the records shows it in a normal “Read Only” form.

Bear in mind that it also supports all of the standard filtering criteria as well so you can filter the views, choose columns etc.

Now how great is that.  I think these Virtual Entities could be one of the best new features for Integrations I have seen in quite a while.  No more having to mess with Web Resources pulling in information from other systems.  No, instead, just treat the data in other systems as part of your main database, read only of course.

Leave a Reply