Virtual Entity - New Way Of Integration - Part One

We have seen this question many times in Dynamics CRM forums, “How can I show my custom db data into CRM forms with saving it into Dynamics CRM?” and the possible options are to develop a custom control using scripting, for example, HTML;  or host a custom report/web page on iframe if you are working with CRM version <9. But now, in Dynamics 365, we can use Virtual Entity to show our data from different sources.

In this article, we are going to discuss Virtual Entities. Virtual Entity is a special type of entity which does not have any SQL table associated with the back-end to store its data under Dynamics 365/CRM database. Instead, it gets the data from different sources with the help of data provider. Mainly, virtual entities consist of three components -

 

  • Data Provider is responsible for bringing the data from external data sources. We can build our own custom data provider or can use OData data provider which is included in Dynamics 365. You can get more details from here to create custom data provider.
  • Data Source is a record in Dynamics 365 which stores the details of the data provider and required connection parameters.
  • Finally, Entity Definition stores the structure of virtual entity just like other entities. It also stores information about which the data source is used for this virtual entity.

We can create virtual entity just like other custom entities by navigating to Settings-> Customization-> Customize the System or we can also create our own custom solution and create virtual entity there. While creating a virtual entity, we need to select Virtual Entity checkbox and need to configure below 4 points.

 

We are using a test service from odata.org as a data source. You can refer to detailed steps here to use the test service from odata.org. External Name is the name of the object that we want to show over the virtual entity and external collection name is the name of the object collection, for example - employee is the object and employees is the name of the collection here. While creating a virtual entity, you need to make sure that the external name and external collection name should match to the entity type name and entity set name exactly.



A Virtual Entity is created with just two out of the box fields - primary id and primary field. But, we can add custom fields and relationships as required. While adding other custom fields, keep in mind that their data type should be exactly mapped to the data type of the external object’s properties. Apart from these, an external object must have a unique key (GUID) which can be mapped to the primary id of the virtual entity.

In the next article, we are going to demonstrate how to write our own OData Web API for Virtual Entity. So, stay tuned!!


Similar Articles
HIMBAP
We are expert in Microsoft Power Platform.