Dynamics 365 - Introduction To Virtual Entity

With the release of Dynamics 365 (Online) in July 2017, the concept of Virtual Entities has been introduced in Dynamics CRM. Virtual Entities as an initial feature supports the basic functionality to read the data from External Sources and present the same as a list or a record in Dynamics CRM.

Overview

With the release of Dynamics 365 (Online) in July 2017, the concept of Virtual Entities has been introduced in Dynamics CRM. Virtual Entities as an initial feature supports the basic functionality to read the data from External Sources and present the same as a list or a record in Dynamics CRM.

What is Virtual Entity?

  • Virtual Entity is a special category of entity for which one has to mark the checkbox as true while creating a new entity. To be precise, it’s an Internal Metadata flag which is marked as true acting as a distinguishing factor for CRM.
  • No entity is stored with existing physical tables in the database. It’s a concept and visualization of data from an external system.
  • A Virtual Data Provider needs to be created which acts as a data source for the virtual entity.
  • When we load the entity in CRM, a request is made to a virtual data provider which retrieves the data from the external system and then represents the same in Read-Only format.

Explanation of Implementation Scenarios

Virtual Entity plays an eminent role wherein the business requirement is just to reflect the data in the CRM from any of the external systems, without occupying any space in the CRM database. The data will just be reflected in the CRM without any actual storage of the same in CRM.

For a developer’s understanding, we can say that Virtual Entity is another capability of Dynamics CRM to process the data from the external system shared as XAML and represent the same as records and views.

 “All Virtual Entities are Read-Only”

Benefits of Virtual Entities

  • The user of the system is able to see the data from external system without logging in to the system, search results and create views along with reports and dashboards
  • Data from an external system can be configured and represented in Dynamics CRM without writing any code
  • Logic through plugins can be implemented by developers on the retrieved message of the virtual entity

Limitations of Virtual Entity

  • Data is read-only, as the term itself explains it: “Virtual” data.
  • Virtual entities support only organization ownership of entities so a user can either see the data or there is no show of data.
  • It must be possible to model the external data as a Dynamics 365 entity. This means,

    • External system ( data source) primary key needs to be of GUID data type

Supported Data Providers

  • OData V4
  • Azure Cosmos DB
  • Custom Data Providers

Diagrammatic Representation

Dynamics 365 - Introduction To Virtual Entity 

Steps for configuration

  • Need to first create Entity as Organizational ownership and mark the flag true to set the entity property to “Virtual Entity”
  • In accordance with requirements of business

    • Need to create Attributes (Data Types)
    • Need to create Views ( Filter Criteria)
    • Need to create reports/dashboards/charts

  • Now, we need to create and decide about the “Data provider”

    • If OData V4 is supported by the external system, then it can be the user directly without any changes.

Implementing OData V4 – Data Provider

  • First of all, we need to create a Data Provider as per our requirement. The same can be created through Administration >> Virtual Entity Data Source.

    Dynamics 365 - Introduction To Virtual Entity
  • Need to configure the Request Parameters for OData as per the requirement of requests
  • New OData v4 Data Source records need to be provided with three "to" fields, available in the general section of the form.

    • Name of the Data Source
    • URL of the Data Source odata.org/V4/OData/OData.svc
    • TimeOut, which is an optional field and mentions after how long the request to the external system will be timed out from CRM
  • We need to create and configure the Virtual Entity as below:

    • Depending upon the response from the external system we need to configure the values for the External Name and External Collection Name values for the entity definition.

      • So, in this example -

        • Name of the new Virtual Entity is called "Advertisement"
        • Name of the Data Source is "Public Service"
        • External Name = "Advertisement"
        • External Collection Name = "Advertisements"
  • Once a new Virtual Entity is created, the mapping of the attributes needs to be done with the values which will be returned as a response to the request to OData.

 You will need to map those to the external data source names.

Dynamics 365 - Introduction To Virtual Entity  

Result

Dynamics 365 - Introduction To Virtual Entity  

Snapshot of OData V4 API Used

Dynamics 365 - Introduction To Virtual Entity  

Feel free to share your queries and, of course, your feedback.