With the release of the Dynamics 365 October service update comes an exciting new capability called Virtual Entities. Virtual entities allow for read-only, no-code integration to other systems right within Dynamics 365 for Sales. Grids, sub-grids, forms, lookups, advanced-find views, reports, and dashboards can all use Virtual Entities. They are also available via all Dynamics 365 online clients and custom applications. Virtual entities are simply a mapping of records and fields from an external data source to a custom Dynamics 365 entity. Dynamics 365 does not store or synchronize with the external data. Let’s take a look at the benefits and limitations of this new functionality. From there, we’ll jump into an example you can try for yourself.
Simpy put, virtual entities can replace the need for time consuming custom integration, replication and synchronization of data. Additionally, it is easy for non-technical customizers to set-up virtual entities and they provide users the ability to work with external data in much the same way that they work with normal Dynamics 365 data.
Limitations of Virtual Entities
- The data source must be exposed via an OData v4 service
- The data exposed through a virtual entity is read-only data
- Only organization-owned entities are supported
- Field-level security is not supported
- The source data must be able to be represented as a Dynamics 365 entity. This means the data must have a GUID primary key, that all its properties can be represented as Dynamics 365 fields, and that any entity relationships in the source system must be able to be modeled the same way within Dynamics 365.
Full technical details from Microsoft can be found here.
How to Make it Work
Let’s take a look at an example. In order to create a virtual entity we will need to:
- Have access to an OData v4 Data Service
- Create a Virtual Entity Data Source in Dynamics 365
- Instantiate a Virtual Entity and the related fields that will display the external data
- Customize 1 or more forms for the new entity
- Create 1 or more views for the new entity
External Data Source
For our example, we will use a publicly available data set that contains Purdue University course information. You can take a look at the metadata here: http://api.purdue.io/odata/$metadata. In particular, we will be using the “Course” entity as shown here:
We will provide access to the following fields in our Dynamics 365 virtual entity:
- Course Number
- Course Title
- Course Credit Hours
- Course Description
If you would like to get a look at the data itself, click here for a complete listing of all the courses in the data set.
Create Virtual Entity Data Source
Now that we have our external data identified, we need to create a Virtual Entity Data Source in Dynamics 365. To do this, Navigate to Settings->Administration->Virtual Entity Data Sources
Once your reach the Virtual Entity Data Source list view you will need to click the “New” command button and select the Odata v4 Data Provider.
Now add the new data source parameters and then the “Save & Close” command button :
- Name: Courses
- URL: http://api.purdue.io/odata/
- Timeout: 60
- Pagination Mode: Client-side Paging
- Return Inline Count: True
You should now see your new data source in the Virtual Entity Data Source list view
Now it’s time to create the virtual entity which will utilize the data source that we just created. Navigate to Settings->Customizations->Customize the System.
Select Entities and then add a new entity.
Create a New Virtual Entity
Create a new Virtual Entity called “Course” with the following field values:
- Display Name: Course
- Plural Name: Courses
- Name: new_course
- External Name: Course
- External Collection Name: Courses
- Virtual Entity: Yes (check the box)
- Data Source: Courses
- Areas that display this entity: Sales (check the Sales box)
Click the “Save” icon and then navigate to the “Fields” tab. Two fields have been automatically created for us. These fields must be mapped to the data source. Let’s start by opening the new_courseid field.
After clicking on the new_courseid field, update the External Name field to CourseId which matches the data source property name and then click “Save and Close.”
Next, do the same for the Name field by updating the External Name field to Title.
Now add a couple more fields to the entity, Credit Hours and Description. Click on the “New” button in the Fields tab and add these fields.
The following 4 fields should exist for the Course entity.
Then we need to update the default view for our Course entity. Navigate to the “All Courses” Default Public View where we will add our Credit Hours and Description fields.
Modify the view to include each of the fields. When finished your view should look like this.
Finally, go ahead and “Publish All Customizations.”
We are ready to give our virtual Course entity a whirl. Navigate to Advanced Find and set the “Look for” entity to Courses and the “Saved View” to All Courses. Then Click “Results”.
Your results should display the courses published by Purdue University at http://api.purdue.io/odata/
Notice that the data set has over 25,000 records. I am showing a record on Page 2 which has some text in the description field. “Moving Across Borders” is the name of the course. See the form and full description by clicking on this record.
And there you have it. Using a virtual entity we have successfully presented data from an external data source as if it existed within a CRM entity. We accomplished this using no code and no third party tools.