使用 Common Data Service 数据库生成应用Generate an app by using a Common Data Service database

[!VIDEO nb:cid:UUID:6d7aa0a1-cd31-47c6-9a32-93b4e5476ece]

可自动生成应用来管理存储在 Common Data Service 中的数据。You can automatically generate an app to manage data that is stored in Common Data Service. 可管理多个标准实体中的一个实体(内置于模型中)或自定义实体(你或组织中的其他人所创建)中的数据。You can manage data in one of the many standard entities that are built into the model, or in a custom entity that you or someone else in your organization creates.

如果不熟悉 Common Data Service,请参阅了解实体If you're unfamiliar with Common Data Service, see Understand entities.

本主题介绍如何自动生成应用,该应用基于所指定的单个实体。This topic describes how to automatically generate an app that is based on a single entity that you specify. 有关如何生成基于多个实体的应用的信息,请参阅从头开始构建应用For information about how to build an app that is based on more than one entity, see Build an app from scratch.

默认情况下,Microsoft PowerApps 生成的每个应用均具有三个屏幕:By default, every app that Microsoft PowerApps generates has three screens:

  • 浏览屏幕显示一个或多个字段的子集、搜索栏和排序按钮,这样用户可以轻松地查找特定记录。The browse screen shows a subset of one or more fields, a search bar, and a sort button that lets users easily find a specific record.
  • 详细信息屏幕显示特定记录的多个字段或所有字段。The details screen shows more or all fields for a specific record.
  • 编辑屏幕提供 UI 元素,用户可在其中创建或更新记录并保存其更改。The edit screen provides UI elements that let users create or update a record and save their changes.

注意:从 Common Data Service 生成应用时,无需像处理 SharePoint、Dynamics 365 和 Salesforce 等数据源那样从 PowerApps 创建连接。Note: When you generate an app from Common Data Service, you don't have to create a connection from PowerApps, as you do for data sources such as SharePoint, Dynamics 365, and Salesforce. 只能指定想要在应用中显示、管理,或同时执行上述两项操作的实体。You must specify only the entity that you want to show, manage, or show and manage in the app.

生成应用Generate an app

  1. 创建 Common Data Service 数据库。Create a Common Data Service database. 有关详细信息,请参阅创建 Common Data Service 数据库For more information, see Create a Common Data Service database.
  2. 在适用于 Windows 的 PowerApps Studio 中,单击或点击“文件”菜单(左边缘附近)上的“新建”。In PowerApps Studio for Windows, click or tap New on the File menu (near the left edge).
  3. 在“开始处理数据”下,在“Common Data Service”磁贴中,单击或点击“Phone 布局”。Under Start with your data, on the Common Data Service tile, click or tap Phone layout.
  4. 在“选择实体”下,单击或点击“联系人”实体。Under Choose an entity, click or tap the Contact entity.
  5. 单击或点击“连接”以自动生成应用。Click or tap Connect to automatically generate an app.

    此时,可能会提示观看介绍性教程。At this point, you may be prompted to take an introductory tour. 稍后,还可以通过单击或点击右上角附近的问号,然后单击或点击“获取简介教程”来获取教程。You can also take the tour later by clicking or tapping the question mark near the upper-right corner, and then clicking or tapping Take the intro tour.

  6. 在左侧导航栏中,单击或点击右上角的图标,切换到缩略图视图。In the left navigation bar, click or tap an icon in the upper-right corner to switch to the thumbnail view.


自定义浏览屏幕Customize the browse screen

  1. 在右侧窗格中,单击或点击仅显示标题的布局。In the right pane, click or tap the layout that shows just a heading.


  2. 在搜索框下,单击或点击“标签”控件以选择它。Under the search box, click or tap the Label control to select it.


  3. 在右侧窗格中,在下拉列表中选择“给定的姓名的姓氏”In the right pane, select Surname of Given name in the dropdown list

    此时,选择的“标签”控件显示这个字段中的数据。The Label control that you selected shows data from that field.

  4. 在浏览屏幕中,单击或点击顶部名称之外的任何名称来选择库。In the browse screen, select the gallery by clicking or tapping any name except the top name.

    选择框会环绕该库。A selection box surrounds the gallery.


  5. 通过选中并按 Ctrl+C 来复制下面的公式。Copy the following formula by selecting it and then pressing Ctrl+C.

    SortByColumns(Search(Contact, TextSearchBox1.Text, "Name_Surname"), "Name_Surname", If(SortDescending1, Descending, Ascending))SortByColumns(Search(Contact, TextSearchBox1.Text, "Name_Surname"), "Name_Surname", If(SortDescending1, Descending, Ascending))

  6. 确保左上角附近的属性列表显示Near the upper-left corner, make sure that the property list shows Items.
  7. 在公式栏中,选择默认公式。In the formula bar, select the default formula.

    Items 属性的默认值

  8. 按 Delete 删除默认公式,然后粘贴复制的公式。Press Delete to delete the default formula, and then paste the formula that you copied. 库中的名称按字母顺序排序。The names in the gallery are sorted alphabetically.

测试浏览屏幕Test the browse screen

  1. 按 F5 或者单击或点击靠近右上角的“播放”按钮即可打开预览模式。Open Preview mode by pressing F5, or by clicking or tapping the Play button near the upper-right corner.
  2. 使用触摸屏或鼠标滚轮滚动浏览所有记录,或者用鼠标指向库以显示滚动条。Scroll through all the records by using a touchscreen or a mouse wheel, or by pointing to the gallery with a mouse so that the scroll bar appears.
  3. 在右上角附近,一次或多次单击或点击排序按钮,以更改名称列出顺序。Near the upper-right corner, click or tap the sort button one or more times to change order that the names are listed in.


  4. 在搜索框中,键入字母以仅显示含该字母的名称。In the search box, type a letter to show only names that contain that letter.
  5. 从搜索框中删除所有文本,然后单击或点击列表中第一个名称右侧的箭头。Remove all text from the search box, and then click or tap the arrow to the right of the first name in the list.

    此时打开详细信息屏幕,并显示所选联系人的详细信息。The details screen opens and shows more information about the contact you selected.

  6. 按 Esc 或者单击或点击右上角附近的标题栏下方的“关闭”按钮即可返回设计工作区。Return to the design workspace by pressing Esc, or by clicking or tapping the Close button near the upper-right corner, under the title bar.

自定义其他屏幕Customize the other screens

  1. 如果详细信息屏幕未显示,单击左侧导航栏中间的缩略图。If DetailScreen isn't showing, click or tap the middle thumbnail in the left navigation bar.
  2. 在“详细信息屏幕”顶部附近,单击或点击“完整名称”以显示用于自定义该屏幕上窗体的选项。Near the top of DetailScreen, click or tap Full name to show options for customizing the form on that screen.
  3. 在右侧窗格中,单击或点击 Name_MiddleName 的眼睛按钮,以隐藏该字段。In the right pane, click or tap the eye button for Name_MiddleName to hide that field.
  4. 在右侧窗格中,单击或点击 的眼睛按钮,以显示该字段。In the right pane, click or tap the eye button for Name_Surname to show that field.
  5. 在右侧窗格中,将 Name_Surname 向上拖动,然后将其置于 Name_GivenName 下方。In the right pane, drag Name_Surname up, and drop it just under Name_GivenName.

    详细信息屏幕将反映所做更改。The DetailScreen reflects your changes.

  6. 在左侧的导航栏中,单击或点击底部缩略图,以显示编辑屏幕,然后重复此过程中的前述步骤,以使编辑屏幕匹配详细信息屏幕In the left navigation bar, click or tap the bottom thumbnail to show EditScreen, and then repeat the previous steps in this procedure so that EditScreen matches DetailScreen.

测试应用程序Test the app

  1. 在左侧导航栏中,单击或点击顶部的缩略图以打开浏览屏幕。In the left navigation bar, click or tap the top thumbnail image to open the browse screen.
  2. 按 F5 或者单击或点击靠近右上角的“播放”按钮即可打开预览模式。Open Preview mode by pressing F5, or by clicking or tapping the Play button near the upper-right corner.
  3. 在浏览屏幕的右上角,单击或点击加号 (+) 图标以创建记录。In the upper-right corner of the browse screen, click or tap the plus sign button (+) to create a record.
  4. 在“名字”和“姓氏”字段中添加文本,然后单击或点击复选标记按钮以保存新记录并返回到浏览屏幕。Add text in the Given name and Surname fields, and then click or tap the check mark button to save your new record and return to the browse screen.
  5. 查找刚创建的记录,然后单击或点击其右侧的箭头以在详细信息屏幕中显示该记录。Find the record that you just created, and then click or tap the arrow to the right of it to show the record on the details screen.
  6. 在右上角,单击或点击铅笔按钮以在编辑屏幕中显示该记录。In upper-right corner, click or tap the pencil button to show the record on the edit screen.
  7. 更改“名字”字段中的数据,然后单击或点击复选标记按钮以保存所做更改。Change the data in the Given name field, and then click or tap the check mark button to save your changes.
  8. 在右上角附近单击或点击回收站按钮,以删除创建和更新的记录。Near the upper-right corner, click or tap the trash-can button to delete the record that you created and updated.

后续步骤Next steps

使用 Common Data Service 数据库从头开始创建应用Create an app from scratch using a Common Data Service database