Canvas PowerApp表单无法从自定义连接器获取字段,从REST API返回表格数据。

问题描述 投票:0回答:1

我创建了一个 定制连接器 我们的REST API,返回 表格数据. 我在一个canvas powerapp中使用它作为一个数据源,它将自定义连接器中的记录存储到了一个名为 "Display "的应用程序中。集合. 这个集合被一个图库用作数据源,它成功地显示了项目和每个项目的属性。然而,当我尝试 创建一个编辑表格 使用 集合 作为数据源,它不能访问字段。它不能直接使用 定制连接器 作为数据源也。

本回答 从@aorphan那里我读到,你可以在表单中使用自定义连接器。只要他们回来 桌子 而不是动作. 而据我所知,该集合的内容是表格数据。DataType is Table

即使是集合的列也可以作为图库显示的项目的属性来访问。ThisItem fields

然而,即使将集合设置为一个新的编辑表单的数据源,它也无法从数据源中添加任何字段。Form add fields

万一我的数据需要更丰富的定义才能被表单正确解释,我的API返回的JSON是这样的。

    {
        "quotes": [
            {
                "quote_pk": 347,
                "shipment_name": "test add leg",
                "organization_ff_name": "LIFE",
                "quote_id": "1234",
                "effective_until": "2020-05-10",
                "eta": "2020-05-14T12:00:00Z",
                "price": 100.0,
                "quote_status": 2
            },
            {
                "quote_pk": 345,
                "shipment_name": "test modal review",
                "organization_ff_name": "LIFE",
                "quote_id": "123",
                "effective_until": "2020-05-11",
                "eta": "2020-05-22T12:00:00Z",
                "price": 1749.94,
                "quote_status": 6
            }
        ]
    }

而我的自定义连接器的定义是这样的:

swagger: '2.0'
info: {title: some title, description: some description, version: '1.0'}
host: server.domain.com
basePath: /organizations/endpoint/
schemes: [https]
consumes: []
produces: []
paths:
  /organizations/endpoint/shipment_quotes/: {}
  /shipment_quotes/:
    get:
      responses:
        '200':
          description: default
          schema:
            type: object
            properties:
              quotes:
                type: array
                items:
                  type: object
                  properties:
                    quote_pk: {type: integer, format: int32, description: quote_pk}
                    shipment_name: {type: string, description: shipment_name}
                    organization_ff_name: {type: string, description: organization_ff_name}
                    quote_id: {type: string, description: quote_id}
                    effective_until: {type: string, description: effective_until}
                    eta: {type: string, description: eta}
                    price: {type: number, format: float, description: price}
                    quote_status: {type: integer, format: int32, description: quote_status}
                description: quotes
      summary: peration summary
      description: operation description
      operationId: operationId
      parameters:
      - {name: Content-Type, in: header, required: false, type: string}
      - {name: Accept, in: header, required: false, type: string}
definitions: {}
parameters: {}
responses: {}
securityDefinitions: {}
security: []
tags: []

请帮助我获得正确的数据源 以便表单能够添加它的字段 或者至少让我知道万一因为某些原因无法添加字段 我就可以继续了

forms canvas powerapps connector
1个回答
1
投票

正式在PowerApps中,集合不能作为表单控件的数据源。你的努力令人钦佩,而且看起来你已经尝试了所有的方法,所以我把我的小秘密告诉你。它可能不受官方支持,所以使用时风险自负。

  1. 从你的自定义连接器中创建一个响应的集合(你已经做了)。
  2. 添加一个图库控件,并设置其 Items 属性到Collection(你已经做了)。
  3. 添加一个编辑表格控件,并设置其 DataSource 属性到Collection(你已经做了)。
  4. 点击三个小点,然后 Add Custom Card
  5. 在自定义卡片中添加一个TextBox控件。
  6. 设置TextBox Default 属性为 gallery.Selected.X 其中 "X "是您要在表格中编辑的值。
  7. 对您希望捕获的每个表单字段重复步骤4-7。
  8. 在表单中创建一个 "提交 "按钮,它是PatchesUpdateIf的集合。然后 从Custom Connector中调用POST(或PUT)方法,将编辑的内容修补回DataSource。

    8a. 我在你的swagger文件中只看到一个GET请求。你将(很明显)需要一个POSTPUT来获取数据。 收藏品 您的DataSource。

    8b. 这个小 "包装器 "很可能是PowerApps为你处理的,当你使用一个 "批准的 "DataSource为一个表单控件。

注意:你的Form将在PowerApps中显示 "无数据源"。 你的Form会在PowerApps studio中显示 "No data source",但你的用户不会看到它。

下面是它的操作。enter image description here

enter image description here

有什么帮助吗?

© www.soinside.com 2019 - 2024. All rights reserved.