创建用于管理项目的应用Create an app to manage projects

备注

本文属于介绍如何将 PowerApps、Microsoft Flow 和 Power BI 与 SharePoint Online 结合使用的系列教程。This article is part of a tutorial series on using PowerApps, Microsoft Flow, and Power BI with SharePoint Online. 请确保已阅读系列介绍,了解总体情况以及相关下载内容。Make sure you read the series introduction to get a sense of the big picture, as well as related downloads.

在此任务中,我们将从头开始生成应用。In this task, we'll build an app from scratch. 使用此应用,用户可以分配项目经理并更新项目详细信息。This app allows a user to assign a manager to projects and to update project details. 将看到第一个应用中的一些相同控件和公式,但这次更多的是自己生成应用。You will see some of the same controls and formulas you saw in the first app, but you will build more of the app yourself this time. 虽然此过程更加复杂,但将能学到更多知识,所以我们认为这样的取舍很公平。The process is more complex, but you'll learn more, so we think it's a fair trade-off.

提示

这个方案的下载包包含此应用的最终版本 (project-details-app.msapp)。The download package for this scenario includes a finished version of this app: project-details-app.msapp.

快速回顾 PowerApps StudioQuick review of PowerApps Studio

虽然在上一任务中也使用了适用于 Web 的 PowerApps Studio,但我们希望确保你在继续浏览本文前了解各个工作区。You used PowerApps Studio for web in the last task, but we want to make sure you understand all the parts before we move on. 可以继续使用适用于 Web 的 PowerApps Studio,也可以使用适用于 Windows 的 PowerApps StudioYou can continue to work in PowerApps Studio for web, or you can use PowerApps Studio for Windows.

PowerApps Studio 有三个窗格和一个功能区,可以在其中创建应用,就像在 PowerPoint 中创建幻灯片一样:PowerApps Studio has three panes and a ribbon that make app creation feel like building a slide deck in PowerPoint:

  1. 左侧导航栏:可以显示所有应用屏幕和控件的分层视图,也可以显示屏幕缩略图Left navigation bar, which shows a hierarchical view of all the app's screens and controls, as well as thumbnails of the screens
  2. 中间窗格:包含正在处理的应用屏幕Middle pane, which contains the app screen you are working on
  3. 右侧窗格:可用于设置布局和数据源等选项Right-hand pane, where you set options like layout and data sources
  4. “属性”下拉列表:可用于选择向其应用公式的属性Property drop-down list, where you select the properties that formulas apply to
  5. 编辑栏:可用于添加公式来定义应用行为(就像在 Excel 中一样)Formula bar, where you add formulas (like in Excel) that define app behavior
  6. 功能区:可用于添加控件和自定义设计元素Ribbon, where you add controls and customize design elements

PowerApps Studio

第 1 步:创建屏幕Step 1: Create screens

在进行上面的回顾后,我们将开始生成应用。With that review out of the way, let's start building an app.

创建并保存应用Create and save the app

  1. 在 PowerApps Studio 中,依次单击或点击“新建”和“空白应用”下的“手机布局”。In PowerApps Studio, click or tap New, then under Blank app, click or tap Phone Layout.

    空白应用 -> 手机布局

  2. 单击或点击“文件”,打开“应用设置”选项卡。输入名称“项目管理应用”。Click or tap File, which opens to an App settings tab. Enter the name "Project Management app".

    应用名称

  3. 单击或点击“另存为”,确认应用是否将保存到云中,再单击右下角的“保存”。Click or tap Save as, verify that the app will save to the cloud, then click Save in the lower right corner.

    保存到云

  4. 单击或点击右上角的Click or tap “返回到应用”图标 ,返回到应用。to go back to the app.

向应用添加四个屏幕Add four screens to the app

在这一步中,我们将为应用创建四个空白屏幕。In this step, we'll create four blank screens for the app. 我们将使用不同的屏幕布局,具体视屏幕的用途而定。We'll use different screen layouts, depending on the screen's purpose. 稍后,我们将添加下面这些屏幕。We'll add to these screens in later steps.

屏幕Screen 用途Purpose
SelectTaskSelectTask 起始屏幕;可转到其他屏幕Opening screen; navigate to other screens
AssignManagerAssignManager 向已获准的项目分配经理Assign a manager to an approved project
ViewProjectsViewProjects 查看包含摘要信息的项目列表View a list of projects, with summary information
UpdateDetailsUpdateDetails 查看和更新项目的详细信息View and update the details for a project
  1. 在“开始”选项卡上,依次单击或点击“新建屏幕”和“可滚动屏幕”。On the Home tab, click or tap NewScreen, then Scrollable screen.

    可滚动屏幕

  2. 将屏幕重命名为“SelectTask”。Rename the screen to SelectTask.

    重命名屏幕

  3. 创建和重命名其他屏幕:Create and rename additional screens:

    1. 依次单击或点击“新建屏幕”和“可滚动屏幕”。Click or tap NewScreen, then Scrollable screen. 将屏幕重命名为“AssignManager”。Rename the screen to AssignManager.
    2. 依次单击或点击“新建屏幕”和“列表屏幕”。Click or tap NewScreen, then List screen. 将屏幕重命名为“ViewProjects”。Rename the screen to ViewProjects.
    3. 依次单击或点击“新建屏幕”和“表单屏幕”。Click or tap NewScreen, then Form screen. 将屏幕重命名为“UpdateDetails”。Rename the screen to UpdateDetails.
  4. 选择“Screen1”旁边的省略号 (...),再单击或点击“删除”。Select the ellipsis (. . .) next to Screen1, then click or tap Delete.

    删除屏幕

此时,应用应如下图所示。The app should now look like the following image.

所有应用屏幕

第 2 步:连接 SharePoint Online 列表Step 2: Connect to a SharePoint list

在这一步中,我们将连接“项目详细信息”SharePoint 列表。In this step, we'll connect to the Product Details SharePoint list. 虽然我们在此应用中只使用一个列表,但可以很容易地连接两个列表(若要扩展应用的话)。We only use one list in this app, but you could easily connect to both if you want to extend the app.

  1. 在左侧导航栏中,单击或点击“SelectTask”屏幕。In the left navigation bar, click or tap the SelectTask screen.
  2. 在右侧窗格中,单击或点击“添加数据源”。In the right pane, click or tap Add data source.

    连接到数据

  3. 单击或点击“新建连接”。Click or tap New connection.

    新建连接

  4. 单击或点击“SharePoint”。Click or tap SharePoint.

    SharePoint 连接

  5. 选择“直接连接(云服务)”,再单击或点击“创建”。Select Connect directly (cloud services), then click or tap Create.

    直接连接(云服务)

  6. 输入 SharePoint URL,再单击或点击“前往”。Enter a SharePoint URL, then click or tap Go.

    SharePoint 连接 URL

  7. 选择“项目详细信息”列表,再单击或点击“连接”。Select the Project Details list, then click or tap Connect.

    选择“项目详细信息”列表

    此时,右侧窗格中的“数据源”选项卡显示已创建的连接。The Data sources tab in the right pane now shows the connection that you have created.

    “数据源”选项卡

第 3 步:生成“SelectTask”屏幕Step 3: Build the SelectTask screen

在这一步中,我们将使用 PowerApps 提供的一些控件、公式和格式化选项,提供一种可转到应用中其他屏幕的途径。In this step, we'll provide a way to navigate to the other screens in the app - working with some of the controls, formulas, and formatting options that PowerApps provides.

更新标题并插入介绍性文字Update the title and insert introductory text

  1. 在左侧导航栏中,选择“SelectTask”屏幕。In the left navigation bar, select the SelectTask screen.
  2. 在中间窗格中,选择默认“[标题]”,再在编辑栏中将“Text”属性更新为“"Contoso Project Management"”。In the middle pane, select the default [Title], then in the formula bar, update the Text property to "Contoso Project Management".

    编辑栏中的“Text”属性

  3. 在“插入”选项卡上,单击或点击“标签”,再将标签向下拖到顶部横幅下方。On the Insert tab, click or tap Label, then drag the label down below the top banner.

    添加标签

  4. 在编辑栏中,为此标签设置下列属性:In the formula bar, set the following properties for the label:

    • “Color”属性的值为“DarkGray”Color property = DarkGray

    • “Size”属性的值为“18”Size property = 18

    • “Text”属性的值为“"Click or tap a task to continue..."”Text property = "Click or tap a task to continue..."

      更新标签文本

添加两个导航按钮Add two navigation buttons

  1. 在“插入”选项卡上,单击或点击“按钮”,再将按钮拖到标签下方。On the Insert tab, click or tap Button, then drag the button below the label.

    “添加”按钮

  2. 在编辑栏中,为此按钮设置下列属性:In the formula bar, set the following properties for the button:

    • “OnSelect”属性的值为“Navigate(AssignManager, Fade)”。OnSelect property = Navigate(AssignManager, Fade). 运行应用并单击此按钮时,将转到应用中的第二个屏幕,并在切换屏幕时采用淡化效果。When you run the app and click this button, you navigate to the second screen in the app, with a fade transition between the screens.

    • “Text”属性的值为“"Assign Manager"”Text property = "Assign Manager"

  3. 重设按钮大小以容纳文本。Resize the button to accommodate the text.

    更新按钮文本

  4. 插入另一个按钮,属性如下:Insert another button with the following properties:

    • “OnSelect”属性的值为“Navigate(ViewProjects, Fade)”。OnSelect property = Navigate(ViewProjects, Fade).

    • “Text”属性的值为“"Update Details"”Text property = "Update Details"

      更新按钮文本

      备注

      虽然此按钮的标签为“更新详细信息”,但会先转到“ViewProjects”屏幕,以选择要更新的项目。The button is labeled Update Details, but we first navigate to the ViewProjects screen to select a project to update.

运行应用Run the app

虽然应用尚不能执行许多操作,但可以根据需要运行应用:The app doesn't do a lot yet, but you can run it if you like:

  1. 单击或点击“SelectTask”屏幕(应用始终以 PowerApps Studio 预览模式中的选定屏幕为起始屏幕)。Click or tap the SelectTask screen (the app always starts from the selected screen in Preview mode in PowerApps Studio).

  2. 单击或点击右上角的Click or tap “运行应用”图标 ,运行应用。in the upper right corner to run the app.

  3. 单击或点击一个按钮,转到其他屏幕。Click or tap one of the buttons to navigate to another screen.

  4. 单击或点击右上角的Click or tap “关闭应用预览”图标 ,关闭应用。in the upper right corner to close the app.

第 4 步:生成“AssignManager”屏幕Step 4: Build the AssignManager screen

在这一步中,我们将使用库来显示所有已获准但尚未分配有经理的项目。In this step, we'll use a gallery to display all projects that have been approved but don't yet have a manager. 我们将添加其他控件,以便用户可以分配经理。We'll add other controls, so you can assign a manager.

备注

虽然稍后将在应用中生成支持编辑项目的所有字段(包括经理字段)的页面,但生成这样的屏幕也很棒。We'll build a page later in the app that allows you to edit all fields for a project (including the manager field), but we thought it would be cool to build a screen like this one as well.

  1. 保存到目前为止所做的更改。Save the changes you've made so far.

  2. 在左侧导航栏中,单击或点击“AssignManager”屏幕。In the left navigation bar, click or tap the AssignManager screen.

更新标题并插入介绍性文字Update the title and insert introductory text

  1. 将“[标题]”更改为“分配经理”。Change [Title] to Assign Manager.

  2. 添加具有以下属性的标签:Add a label with the following properties:

    • “Color”属性的值为“DarkGray”Color property = DarkGray

    • “Size”属性的值为“18”Size property = 18

    • “Text”属性的值为“"Select a project, then assign a manager"”Text property = "Select a project, then assign a manager"

      “AssignManager”屏幕布局

添加用于返回到“SelectTask”屏幕的后退箭头Add a back arrow to return to the SelectTask screen

  1. 单击或点击屏幕顶部附近的蓝色条。Click or tap the blue bar at the top of the screen.

  2. 在“插入”选项卡上,依次单击或点击“图标”和“向左”。On the Insert tab, click or tap Icons, then click or tap Left.

    插入向左箭头

  3. 将此箭头移到蓝色条的左侧,并设置下列属性:Move the arrow to the left side of the blue bar, and set the following properties:

    • “Color”属性的值为“White”Color property = White

    • “Height”属性的值为“40”Height property = 40

    • “OnSelect”属性的值为“Navigate(SelectTask, Fade)”OnSelect property = Navigate(SelectTask, Fade)

    • “Width”属性的值为“40”Width property = 40

      添加返回按钮

  1. 在“插入”选项卡上,依次单击或点击“库”和“垂直”。On the Insert tab, click or tap Gallery, then Vertical.

    添加垂直库

  2. 从右侧窗格的“布局”菜单中选择“标题、副标题和正文”。Select Title, subtitle, and body from the Layout menu in the right pane.

    更改库布局

    此时,库拥有正确的布局,但仍显示默认示例文本。The gallery now has the right layout, but it still has the default sample text. 接下来,我们将解决此问题。We'll fix that next.

    显示默认文本的库

  3. 为此库设置下列属性:Set the following properties for the gallery:

    • “BorderThickness”属性的值为“1”BorderThickness property = 1

    • “BorderStyle”属性的值为“Dotted”BorderStyle property = Dotted

    • “Items”属性的值为“Filter('Project Details', PMAssigned="Unassigned")”。Items property = Filter('Project Details', PMAssigned="Unassigned"). 库中仅包含没有分配经理的项目。Only projects with no manager assigned are included in the gallery.

      显示列表文本的库

  4. 在右侧窗格中,将字段更新为与以下列表一致:In the right pane, update the fields to match the following list:

    • ApprovedDateApprovedDate

    • StatusStatus

    • TitleTitle

      库字段

  5. 适当重设库中标签大小,并从库中首项中删除箭头(无需从此库转到任何位置)。Resize labels in the gallery as appropriate, and remove the arrow from the first gallery item (we don't need to navigate anywhere from this gallery).

    删除箭头图标

    此时,屏幕应如下图所示。The screen should now look like the following image.

    已设置格式的库

更改选定项的颜色Change the color of an item if it's selected

  1. 选择库,并将“TemplateFill”属性设置为“If (ThisItem.IsSelected=true, Orange, White)”。Select the gallery, then set the TemplateFill property to If (ThisItem.IsSelected=true, Orange, White).

  2. 在库中选择一项。Select an item in the gallery. 此时,屏幕应如下图所示。The screen should now look like the following image.

    包含选定项的库

添加用于提交项目经理分配的标签、文本输入框和“确定”按钮Add a label, text input, and OK button to submit manager assignments

  1. 单击或点击一直在处理的库外部。Click or tap outside the gallery you've been working on.

  2. 在“插入”选项卡上,单击或点击“标签”。On the Insert tab, click or tap Label. 将此标签拖到库下面的左侧位置上。Drag the label below the gallery, to the left. 为此标签设置下列属性:Set the following properties for the label:

    • “Size”属性的值为“20”Size property = 20

    • “Text”属性的值为“"Manager:"”Text property = "Manager:"

    添加“Manager:”标签

  3. 在“插入”选项卡上,依次单击或点击“文本”和“文本输入”。On the Insert tab, click or tap Text, then Text input. 将此文本输入框拖到库下面的中心位置上。Drag the text input below the gallery, in the center. 为此下拉框设置下列属性:Set the following properties for the drop down:

    • “Default”属性的值为“""”Default property = ""

    • “Height”属性的值为“60”Height property = 60

    • “Size”属性的值为“20”Size property = 20

    • “Width”属性的值为“250”Width property = 250

    添加文本输入框

  4. 在“插入”选项卡上,单击或点击“按钮”。On the Insert tab, click or tap Button. 将此按钮拖到库下面的右侧位置上。Drag the button below the gallery, to the right. 为此按钮设置下列属性:Set the following properties for the button:

    • “Height”属性的值为“60”Height property = 60

    • “OnSelect”属性的值为“Patch('Project Details', LookUp('Project Details', ID = Gallery1.Selected.ID), {PMAssigned: TextInput1.Text})”。OnSelect property = Patch('Project Details', LookUp('Project Details', ID = Gallery1.Selected.ID), {PMAssigned: TextInput1.Text}). 有关详细信息,请参阅公式详解For more information, see Formula deep-dive.

    • 此公式用于更新“项目详细信息”列表,同时设置“PMAssigned”字段值。This formula updates the Project Details list, setting a value for the PMAssigned field.

    • “Size”属性的值为“20”Size property = 20

    • “Text”属性的值为“"OK"”Text property = "OK"

    • “Width”属性的值为“80”Width property = 80

    添加“确定”按钮

此时,完成的屏幕应如下图所示。The completed screen should now look like the following image.

完成的“AssignManager”屏幕

第 5 步:生成“ViewProjects”屏幕Step 5: Build the ViewProjects screen

在这一步中,我们将更改“ViewProjects”屏幕上库的属性。In this step, we'll change properties for the gallery on the ViewProjects screen. 此库显示“项目详细信息”列表中的项。This gallery displays items from the Project Details list. 先在此屏幕上选择一项,再在“UpdateDetails”屏幕上编辑详细信息。You select an item on this screen, then you edit the details on the UpdateDetails screen.

  1. 在左侧导航栏中,单击或点击“ViewProjects”屏幕。In the left navigation bar, click or tap the ViewProjects screen.

  2. 将“[标题]”更改为“查看项目”。Change [Title] to "View Projects".

  3. 在左侧导航栏中,单击或点击“ViewProjects”下的“BrowserGallery1”。In the left navigation bar, click or tap BrowserGallery1 under ViewProjects.

  4. 从右侧窗格的“布局”菜单中选择“标题、副标题和正文”。Select Title, subtitle, and body from the Layout menu in the right pane.

    更改库布局

    此时,库拥有正确的布局,但仍显示默认示例文本。The gallery now has the right layout, with the default sample text.

    显示默认文本的库

  5. 选择“刷新”按钮 “刷新”图标,并将“OnSelect”属性设置为“Refresh('Project Details')”。Select the refresh button Refresh icon, and set its OnSelect property to Refresh('Project Details').

  6. 选择“新建项”按钮 “添加新项”图标,并将“OnSelect”属性设置为“NewForm(EditForm1); Navigate(UpdateDetails, ScreenTransition.None)”。Select the new item button Add new icon, and set its OnSelect property to NewForm(EditForm1); Navigate(UpdateDetails, ScreenTransition.None).

添加用于返回到“SelectTask”屏幕的后退箭头Add a back arrow to return to the SelectTask screen

  1. 在左侧导航栏中,单击或点击“AssignManager”屏幕。In the left navigation bar, click or tap the AssignManager screen.

  2. 选择并复制在此屏幕中添加的后退箭头。Select the back arrow you added there, and copy it.

  3. 将箭头粘贴到“ViewProjects”屏幕中,再将它放置在“刷新”按钮的左侧。Paste the arrow into the ViewProjects screen and position it to the left of the refresh button.

    返回按钮

    后退箭头的所有属性都会随之转移,包括“Navigate(SelectTask, Fade)”的“OnSelect”属性。All its properties come along with it, including the OnSelect property of Navigate(SelectTask, Fade).

  1. 选择“BrowseGallery1”库,并将库的“Items”属性设置为“SortByColumns(Filter('Project Details', StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))”。Select the BrowseGallery1 gallery, and set the Items property of the gallery to SortByColumns(Filter('Project Details', StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending)).

    这会将库的数据源设置为“项目详细信息”列表,并按“Title”字段进行搜索和排序。This sets the data source of the gallery to the Project Details list, and uses the Title field for search and sort.

  2. 选择库中首项的 “详细信息箭头”图标,并将“OnSelect”属性设置为“Navigate(UpdateDetails, None)”。Select the Details arrow icon in the first gallery item, and set the OnSelect property to Navigate(UpdateDetails, None).

     <span data-ttu-id="8f40b-322">“ViewProjects”屏幕库 -> 选择首项</span><span class="sxs-lookup"><span data-stu-id="8f40b-322">View Projects gallery - first item selected</span></span>

  3. 在右侧窗格中,将字段更新为与以下列表一致:In the right pane, update the fields to match the following list:

    • StatusStatus

    • PMAssignedPMAssigned

    • TitleTitle

      库字段

      此时,完成的屏幕应如下图所示。The completed screen should now look like the following image.

      完成的“ViewProjects”屏幕

第 6 步:生成“UpdateDetails”屏幕Step 6: Build the UpdateDetails screen

在这一步中,我们将把“UpdateDetails”屏幕上的编辑表单与我们的数据源相连,并更改一些属性和字段。In this step, we'll connect the edit form on the UpdateDetails screen to our data source, and we'll make some property and field changes. 在此屏幕上,可以编辑在“ViewProjects”屏幕上选择的项目的详细信息。On this screen, you edit details for a project that you selected on the View Projects screen.

  1. 在左侧导航栏中,单击或点击“UpdateDetails”屏幕。In the left navigation bar, click or tap the UpdateDetails screen.

  2. 将“[标题]”更改为“更新详细信息”。Change [Title] to "Update Details".

  3. 在左侧导航栏中,单击或点击“UpdateDetails”下的“EditForm1”。In the left navigation bar, click or tap EditForm1 under UpdateDetails.

  4. 为此表单设置下列属性:Set the following properties for the form:

    • “DataSource”属性的值为“Project Details”DataSource property = 'Project Details'

    • “Item”属性的值为“BrowseGallery1.Selected”Item property = BrowseGallery1.Selected

  5. 在仍选择此表单的情况下,在右侧窗格中单击或点击选中以下字段的复选框,顺序如下:With the form still selected, in the right pane click or tap the checkbox for the following fields, in the order shown:

    • TitleTitle

    • PMAssignedPMAssigned

    • StatusStatus

    • ProjectedStartDateProjectedStartDate

    • ProjectedEndDateProjectedEndDate

    • ProjectedDaysProjectedDays

    • ActualDaysActualDays

      “编辑表单”字段

  6. 选择“取消”按钮 “取消”图标,并将“OnSelect”属性设置为“ResetForm(EditForm1); Back()”。Select the cancel button Cancel icon, and set its OnSelect property to ResetForm(EditForm1); Back().

  7. 选择“保存”按钮 复选标记“保存”图标,并检查“OnSelect”公式是否为“SubmitForm(EditForm1)”。Select the save button Checkmark save icon and check out the OnSelect formula - SubmitForm(EditForm1). 由于我们使用的是“编辑表单”控件,因此可以使用“Submit()”,而不是我们之前使用的“Patch()”。Because we're using the edit form control, we can use Submit(), instead of using Patch() like we did earlier.

此时,完成的屏幕应如下图所示(如果字段为空白,请务必在“ViewProjects”屏幕上选择一项)。The completed screen should now look like the following image (if the fields are blank, make sure you select an item on the View Projects screen).

“UpdateDetails”屏幕已完成

第 7 步:运行应用Step 7: Run the app

至此,应用已创建完成。我们将运行应用,看看它能否正常运行。Now that the app is complete, let's run it to see how it works. 我们将在 SharePoint 网站上添加应用链接。We'll add a link on the SharePoint site to the app. 虽然可以在浏览器中运行应用,但可能必须先共享应用,然后其他人才能运行。You will be able to run the app in the browser, but you might need to share the app for other people to run it. 有关详细信息,请参阅共享应用For more information, see Share your apps.

  1. 在 Office 365 应用启动器中,单击或点击“PowerApps”。In the Office 365 app launcher, click or tap PowerApps.

    Office 365 应用启动器中的“PowerApps”

  2. 在 PowerApps 中,依次单击或点击“项目管理应用”旁边的省略号 (...) 和“打开”。In PowerApps, click or tap the ellipsis (. . .) for Project Management app, then Open.

    选择“项目管理应用”

  3. 复制浏览器中的应用地址 (URL)。Copy the address (URL) for the app in the browser.

    复制应用 URL

  4. 在 SharePoint 中,单击或点击“编辑链接”。In SharePoint, click or tap EDIT LINKS.

    编辑 SharePoint 网站链接

  5. 单击或点击“(+)链接”。Click or tap (+) link.

    将应用链接添加到 SharePoint 网站

  6. 输入“项目管理应用”,再粘贴应用地址。Enter "Project Management app", and paste in the address for the app.

    编辑链接属性

  7. 依次单击或点击“确定”和“保存”。Click or tap OK, then Save.

    保存链接更改

向项目分配经理Assign a manager to a project

至此,应用已位于 SharePoint 网站中。我们将担任项目审批者的角色,查找任何没有分配经理的项目,并向其中一个项目分配经理。Now that we have the app in our SharePoint site, we'll assume the role of the project approver - we'll look for any projects that don't have a manager assigned, and assign a manager to one of the projects. 然后,我们将担任项目经理的角色,添加一些有关已分配给我们的项目的信息。Then we'll assume the role of the project manager, and add some information about a project that is assigned to us.

  1. 首先,我们将查看 SharePoint 中的“项目详细信息”列表。First, let's look at the Project Details list in SharePoint. 两个项目的“PMAssigned”列的值为“Unassigned”。Two projects have a value of Unassigned in the PMAssigned column. 我们将在应用中查看这两个项目。We will see these in the app.

    SharePoint 列表中的未分配项目

  2. 单击或点击已创建的应用链接。Click or tap the link that you created to the app.

  3. 在第一屏上,单击或点击“分配经理”。On the first screen, click or tap Assign Manager.

    应用起始屏幕

  4. 在“分配经理”屏幕上,可以看到列表中的两个未分配项目。On the Assign Manager screen, you see the two unassigned projects from the list. 选择“新建 BI 软件”项目。Select the New BI software project.

    包含选定项的库

  5. 在“经理”文本输入框中,输入“Joni Sherman”,再单击“确定”。In the Manager text input, enter "Joni Sherman", then click OK.

    此更改已应用于列表,并且库会进行刷新,因此只会显示剩余未分配的项目。The change is applied to the list, and the gallery refreshes so only the remaining unassigned project is displayed.

    向项目分配经理

  6. 返回到 SharePoint 列表,并刷新页面。Go back to the SharePoint list and refresh the page. 可以看到,项目条目现已更新为包含项目经理姓名。You'll see that the project entry is now updated with the project manager name.

    SharePoint 列表中的已分配项目经理

更新项目详细信息Update details for the project

  1. 单击或点击 “返回”图标,返回到第一屏,再单击或点击“更新详细信息”。Click or tap Back icon to go back to the first screen, then click or tap Update Details.

    应用起始屏幕

  2. 在“查看项目”屏幕上的搜索框中输入“新建”。On the View Projects screen, enter "New" in the search box.

    在应用库中搜索

  3. 单击“新建 BI 软件”项的 “详细信息箭头”图标Click Details arrow icon for the New BI software item.

    选定的库项

  4. 在“更新详细信息”屏幕上,设置以下值:On the Update Details screen, set the following values:

    • “ProjectedStartDate”字段的值为“3/6/2017”The ProjectedStartDate field = "3/6/2017"

    • “ProjectedEndDate”字段的值为“3/24/2017”The ProjectedEndDate field = "3/24/2017"

    • “ProjectedDays”字段的值为“15”The ProjectedDays field = "15"

    更新项详细信息

  5. 单击或点击右上角的Click or tap 复选标记图标 ,将更改应用于 SharePoint 列表。to apply the change to the SharePoint list.

  6. 关闭应用,再返回到列表。Close the app, and go back to the list. 可以看到,项目条目现已更新为包含更改后的日期和天数。You see that the project entry is now updated with the date and day changes.

    更新后的 SharePoint 列表

公式详解Formula deep-dive

这是第二个有关 PowerApps 公式的选读部分。This is the second optional section on PowerApps formulas. 在第一个公式详解部分中,我们探究了 PowerApps 为三屏应用中的浏览库生成的公式之一。In the first deep-dive, we looked at one of the formulas that PowerApps generates for the browse gallery in a three-screen app. 在本次详解中,我们将探究对第二个应用的“AssignManager”屏幕使用的公式。In this deep-dive, we'll look at a formula that we use for the AssignManager screen of our second app. 公式如下:Here's the formula:

Patch ( 'Project Details', LookUp ( 'Project Details', ID = Gallery1.Selected.ID ), {PMAssigned: TextInput1.Text} )Patch ( 'Project Details', LookUp ( 'Project Details', ID = Gallery1.Selected.ID ), {PMAssigned: TextInput1.Text} )

此公式有何用途?What does this formula do? 在库中选择一项并单击“确定”按钮后,此公式便会更新“项目详细信息”列表,将“PMAssigned”列设置为在文本输入框中指定的值。When you select an item in the gallery and click the OK button, the formula updates the Project Details list, setting the PMAssigned column to the value that you specify in the text input. 此公式使用以下函数来实现用途:The formula uses functions to do its work:

  • Patch 函数:用于修改数据源中的一条或多条记录。The Patch function modifies one or more records of a data source.

  • LookUp 函数:用于查找表中首条满足公式的记录。The LookUp function finds the first record in a table that satisfies a formula.

在此公式中结合使用这些函数后的情况如下:When you put the functions together in the formula, here's what happens:

  1. 单击“确定”按钮后,将调用“Patch”函数来更新“项目详细信息”列表。When you click the OK button, the Patch function is called to update the Project Details list.

  2. 在“Patch”函数中,“LookUp”函数标识要更新“项目详细信息”列表中的哪一行。Within the Patch function, the LookUp function identifies which row of the Project Details list to update. 为此,它会比较选定库项的 ID 与列表中的 ID。It does this by comparing the ID of the selected gallery item to the ID in the list. 例如,ID 为 12 表示应更新“新建 BI 软件”的条目。For example, an ID of 12 means that the entry for New BI software should be updated.

  3. 至此,“Patch”函数包含正确的 ID,可以将“PMAssigned”字段更新为“TextInput1.Text”中的值。Now that the Patch function has the right ID, it updates the PMAssigned field to the value in TextInput1.Text.

后续步骤Next steps

本系列教程的下一步是创建用于分析项目的 Power BI 报表The next step in this tutorial series is to create a Power BI report to analyze projects.