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, entity is now table and field is now columnLearn 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.

  1. Go to Settings > Administration > Virtual table Data Sources.

  2. Select NEW, select OData v4 Data Provider, and then select OK.

  3. 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

  1. From the Power Apps portal select Solutions, and then on the toolbar, select Switch to classic.

  2. In the All Solutions list select the unmanaged solution you want.

Create the virtual table

  1. In the left navigation pane of solution explorer, select Tables, and then select New from the main pane.

  2. 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
  3. Next to Areas that display this table, select Service, and then select Save (but don’t close the table form). Virtual Table on Power Apps with OData

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.

  1. Open the new_ticketid column, and change the following attribute with the value indicated here: External Name: TicketID Virtual Table on Power Apps with OData

  2. Select Save and Close.

  3. Open the new_name column, and change the following attributes to have the values indicated here:

    • Display Name: Title
    • External Name: Title Virtual Table on Power Apps with OData
  4. Select Save and Close.

  5. 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

Virtual Table on Power Apps with OData

  1. Select Save and Close.

Add the columns to the Main form

  1. On the Ticket table window, select Forms.
  2. Open the main form, drag and drop the Severity column from the right pane onto the form in the Generalsection under the Title column. Virtual Table on Power Apps with OData
  3. On the Ticket table window select Save and Close.

Configure the default view

  1. On the left pane of the solution explorer, under the Ticket table, select Views.
  2. Open the All Tickets view.
  3. In the Common Tasks pane select Add Columns. Virtual Table on Power Apps with OData
  4. Select Severity, and then select OK.
  5. On the View: All Tickets window select Save and Close.
  6. On the Solution Explorer window select Publish All Customizations. Virtual Table on Power Apps with OData
  7. After all customizations are published, close the Solution Explorer window.

View the virtual table in action with Dynamics 365

  1. Go to Service > Extensions > Tickets.

    Virtual Table on Power Apps with OData

    The All Tickets view displays. Notice that you may need to refresh your browser to view the table from the Service area.

    Virtual Table on Power Apps with OData

  2. Open a Ticket row to view the form that includes the Title and Severity columns for the given row. Virtual Table on Power Apps with OData

 

Virtual Table on Power Apps with OData

上一篇:idea springboot 无法启动 Unable to start EmbeddedWebApplicationContext


下一篇:279 Android基本布局之1—线性布局、相对布局(重点)