Virtual Table on Power Apps with OData
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,entityis nowtableandfieldis nowcolumn.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:
XML<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 toSettings>Administration>Virtual table Data Sources.
-
SelectNEW, selectOData v4 Data Provider, and then selectOK.
-
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 selectSAVE & 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 selectSolutions, and then on the toolbar, selectSwitch to classic.
-
In theAll Solutionslist select the unmanaged solution you want.
Create the virtual table
-
In the left navigation pane of solution explorer, selectTables, and then selectNewfrom the main pane.
-
On thetable: Newform, select theVirtual tableoption, 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 toAreas that display this table, selectService, and then selectSave(but don’t close the table form).
Create the columns for the virtual table
On the left navigation pane of thetable: Ticketpage, selectColumns. 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 thenew_ticketidcolumn, and change the following attribute with the value indicated here:External Name: TicketID
-
SelectSave and Close.
-
Open thenew_namecolumn, and change the following attributes to have the values indicated here:
- Display Name: Title
- External Name: Title
-
SelectSave and Close.
-
SelectNew, and on theField: New for Ticketpage 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
- SelectSave and Close.
Add the columns to the Main form
- On the Ticket table window, selectForms.
- Open the main form, drag and drop theSeveritycolumn from the right pane onto the form in theGeneralsection under theTitlecolumn.
- On the Ticket table window selectSave and Close.
Configure the default view
- On the left pane of the solution explorer, under theTicket table, selectViews.
- Open theAll Ticketsview.
- In theCommon Taskspane selectAdd Columns.
- SelectSeverity, and then selectOK.
- On theView: All Ticketswindow selectSave and Close.
- On the Solution Explorer window selectPublish All Customizations.
- After all customizations are published, close the Solution Explorer window.
View the virtual table in action with Dynamics 365
-
Go toService>Extensions>Tickets.
TheAll Ticketsview displays. Notice that you may need to refresh your browser to view the table from theServicearea.
-
Open aTicketrow to view the form that includes theTitleandSeveritycolumns for the given row.