Virtual table walkthrough using the OData v4 Data Provider
Effective November 2020:
- Common Data Service has been renamed to Microsoft Dataverse. Learn more
- Some terminology in Microsoft Dataverse has been updated. For example, entity is now table and field is now column. Learn more
This article will be updated soon to reflect the latest terminology.
Imagine that you want to access ticket information from an external data source within your model-driven app. In this simple walkthrough, you‘ll model a virtual table with columns mapped to the external schema that retrieves ticket data at runtime from an OData web service.
Data source details
Because the data source used for this walkthrough has an OData v4 web service, we can use the OData v4 Data Provider included with your environment.
Web service url: https://contosowebservice.azurewebsites.net/odata/
Important
The web service url used for this walkthrough isn‘t a functioning web service.
For this walkthrough, a single virtual table that contains the following three columns is needed.
External column name | External data type | Virtual table data type | Purpose |
---|---|---|---|
TicketID | Edm.Guid |
Primary key | Primary key for the table |
Title | Edm.String |
Single Line of Text | Title of the ticket |
Severity | Edm.Int32 |
Whole Number | Number value of 0-4 indicating the severity of the ticket |
The OData metadata of the external data source Ticket table:
<tableType Name="Ticket">
<Key>
<PropertyRef Name="TicketID" />
</Key>
<Property Name="TicketID" Nullable="false" Type="Edm.Guid" />
<Property Name="Title" Type="Edm.String" />
<Property Name="Severity" Nullable="false" Type="Edm.Int32" />
</tableType>
Create the Data Source
Create the data source for the OData v4 data provider that uses the OASIS Open Data Protocol (OData) sample web service.
-
Go to Settings > Administration > Virtual table Data Sources.
-
Select NEW, select OData v4 Data Provider, and then select OK.
-
Enter or select the following information.
Field Value Name Contoso Sample Data Source URL https://contosowebservice.azurewebsites.net/odata
Timeout 30 Return Inline Count True
Leave the other columns as-is, and select SAVE & CLOSE.
Tip
When using your own web service, verify that the URL is valid by pasting it in to your web browser.
Open solution explorer
Part of the name of any custom table you create is the customization prefix. This is set based on the solution publisher for the solution you’re working in. If you care about the customization prefix, make sure that you are working in an unmanaged solution where the customization prefix is the one you want for this table. More information: Change the solution publisher prefix
Navigate to an unmanaged solution
-
From the Power Apps portal select Solutions, and then on the toolbar, select Switch to classic.
-
In the All Solutions list select the unmanaged solution you want.
Create the virtual table
-
In the left navigation pane of solution explorer, select Tables, and then select New from the main pane.
-
On the table: New form, select the Virtual table option, and then enter the following information:
Field Value Data Source Contoso Sample Data Source Display Name Ticket Plural Name Tickets Name new_ticket External Name Ticket External Collection Name Tickets Notes (includes attachments) selected Activities selected -
Next to Areas that display this table, select Service, and then select Save (but don’t close the table form).
Create the columns for the virtual table
On the left navigation pane of the table: Ticket page, select Columns. As part of this walkthrough you will edit two existing columns and add a third column.
Important
External names are case sensitive. Refer to your web service metadata to make sure you use the correct name. A Nullable value of false indicates that the attribute is required. Notice that primary key columns are always system required.
-
Open the new_ticketid column, and change the following attribute with the value indicated here: External Name: TicketID
-
Select Save and Close.
-
Open the new_name column, and change the following attributes to have the values indicated here:
- Display Name: Title
- External Name: Title
-
Select Save and Close.
-
Select New, and on the Field: New for Ticket page enter the following information:
Field Value Display Name Severity Name new_severity External Name Severity Field Requirement Business Required Data Type Whole Number Minimum Value 0 Maximum Value 4
- Select Save and Close.
Add the columns to the Main form
- On the Ticket table window, select Forms.
- Open the main form, drag and drop the Severity column from the right pane onto the form in the Generalsection under the Title column.
- On the Ticket table window select Save and Close.
Configure the default view
- On the left pane of the solution explorer, under the Ticket table, select Views.
- Open the All Tickets view.
- In the Common Tasks pane select Add Columns.
- Select Severity, and then select OK.
- On the View: All Tickets window select Save and Close.
- On the Solution Explorer window select Publish All Customizations.
- After all customizations are published, close the Solution Explorer window.
View the virtual table in action with Dynamics 365
-
Go to Service > Extensions > Tickets.
The All Tickets view displays. Notice that you may need to refresh your browser to view the table from the Service area.
-
Open a Ticket row to view the form that includes the Title and Severity columns for the given row.