Effective November 2020:
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.
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 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.
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
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.
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).
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:
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 |
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.
Virtual Table on Power Apps with OData
原文:https://www.cnblogs.com/lingdanglfw/p/14005467.html