创建用于管理项目审批的流Create a flow to manage project approvals

备注

本文属于介绍如何将 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 create a flow that drives the process of approving projects. 由于 Microsoft Flow 已与 SharePoint 集成,因此可以很容易地直接通过列表创建流。Microsoft Flow is integrated with SharePoint, so it's easy to create a flow directly from a list. 当“项目申请”列表添加有新项时,将会触发我们创建的流。The flow we'll create is triggered when an item is added to the Project Requests list. 此流会向项目审批者发送电子邮件,以便其可以直接在电子邮件中批准或拒绝申请。The flow sends an email to the project approver, who approves or rejects the request directly in email. 然后,此流会向项目申请者发送批准或拒绝电子邮件,并相应地更新 SharePoint 列表。The flow then sends an approval or rejection email to the project requestor and updates our SharePoint lists appropriately.

第 1 步:配置流模板Step 1: Configure the flow template

  1. 在“项目申请”列表中,依次单击或点击“流”和“创建流”。In the Project Requests list, click or tap Flow, then Create a flow.

    创建流

  2. 在右侧窗格中,单击或点击“添加新项后开始审批”。In the right pane, click or tap Start approval when a new item is added.

    创建审批流

  3. 如果尚未登录,请先登录 SharePoint 和 Outlook,再单击或点击“继续”。If you're not already signed in, sign into SharePoint and Outlook, then click or tap Continue.

    登录以使用模板

    此时,可以看到此流的模板,随时可以填写。You now see the template for this flow, ready for you to complete. 此流中的框表示步骤。The boxes in the flow represent steps. 这些步骤需要使用前面步骤中的输入,以及你提供的输入。They take input from previous steps, as well as input that you provide. 然后,每个步骤便可以向后续步骤提供输出。Each step can then provide output to subsequent steps.

    审批模板

  4. 在“分配到”框中,输入租户中的有效名称。In the Assigned To box, enter a name that is valid in your tenant.

    审批电子邮件联系人

    此流中的下一个框对应于项目审批者的决定,并将此流路由到两个分支(“If yes”或“If no”)之一。The next box in the flow responds to the project approver's decision and routes the flow to one of two branches: If yes or If no.

    审批条件

第 2 步:创建“Approve”值为“yes”时的操作Step 2: Create actions for Approve = yes

默认情况下,此分支将批准电子邮件发送给申请者。By default, this branch sends an approval email to the requestor. 我们还会更新“项目申请”列表,并将项添加到“项目详细信息”列表中,因为此项目已获准。We'll also update the Project Requests list, and add an item to the Project Details list because the project has been approved.

  1. 在“If yes”分支中,依次单击或点击“通知项创建者已获准”和“编辑”,调出发送给申请者的电子邮件的默认选项。In the If yes branch, click or tap Inform item creator of approval, then Edit to see the default options for the email sent to the requestor.

    编辑电子邮件设置

  2. 默认情况下,将会向列表项创建者发送电子邮件,主题行和消息正文与你看到的一样。By default, an email is sent to the person who created the list item, with the subject line and message body that you see. 可以根据需要更新这些内容。You can update these if you like.

    默认电子邮件设置

  3. 单击或点击“添加操作”。Click or tap Add an Action.

    添加操作

  4. 在“选择操作”下,搜索“SharePoint”,再单击或点击“SharePoint - 更新项”。Under Choose an action, search for "SharePoint", then click or tap SharePoint – Update item.

    “更新项”操作

  5. 输入 SharePoint 网站 URL 和列表名称。Enter the SharePoint site URL and list name.

    “更新项”参数

  6. 选择“ID”框,再单击或点击“动态内容”对话框中的“ID”。Select the Id box, then click or tap ID in the dynamic content dialog box.

    列出 ID 动态内容

    根据前面的步骤,动态内容在整个流中都可用。Dynamic content is available throughout the flow, based on previous steps. 在此示例中,SharePoint 列表信息可用。因此,我们可以将其用于所创建的操作。In this case, the SharePoint list information is available, and we can use it in the actions that we create.

  7. 选择“Title”框,在“动态内容”对话框中搜索“Title”,再单击或点击“Title”。Select the Title box, search for "Title" in the dynamic content dialog box, then click or tap Title.

    列出标题动态内容

  8. 在“已批准”框中,输入“是”。In the Approved box, enter "Yes". 此时,这部分流应如下图所示。This part of the flow should now look like the following image.

    列表更新

  9. 再次单击或点击“添加操作”。Click or tap Add an Action again. 这次我们将向已获准项目的“项目详细信息”列表添加一项。This time we'll add an item to the Project Details list for the project that was approved.

    添加操作

  10. 在“选择操作”下,搜索“SharePoint”,再选择“SharePoint - 创建项”。Under Choose an action, search for "SharePoint", then select SharePoint – Create item.

    “创建项”操作

  11. 输入 SharePoint 网站 URL 和列表名称。Enter the SharePoint site URL and list name.

    “创建项”参数

  12. 选择“Title”框,在“动态内容”对话框中搜索“Title”,再单击或点击“Title”。Select the Title box, search for "Title" in the dynamic content dialog box, then click or tap Title.

    列出标题动态内容

  13. 选择“RequestId”框,再单击或点击“动态内容”对话框中的“ID”。Select the RequestId box, then click or tap ID in the dynamic content dialog box.

    列出 ID 动态内容

  14. 在“PMAssigned”框中,输入“Unassigned”。In the PMAssigned box, enter "Unassigned". 此时,这部分流应如下图所示。This part of the flow should now look like the following image.

    项创建已完成

第 3 步:检查“Approve”值为“no”时的操作Step 3: Review action for Approve = no

默认情况下,此分支将拒绝电子邮件发送给申请者。By default, this branch sends a rejection email to the requestor. 我们还会更新“项目申请”列表。We'll also update the Project Requests list. 此项目不会有任何进展,因此我们不会将项添加到“项目详细信息”列表中。The project isn't moving forward, so we don't add an item to the Project Details list.

  1. 在“If no”分支中,依次单击或点击“通知项创建者已遭拒”和“编辑”,调出发送给申请者的电子邮件的默认选项。In the If no branch, click or tap Inform item creator of rejection, then Edit to see the default options for the email sent to the requestor.

    编辑电子邮件设置

  2. 默认情况下,将会向列表项创建者发送电子邮件,主题行和消息正文与你看到的一样。By default, an email is sent to the person who created the list item, with the subject line and message body that you see. 可以根据需要更新这些内容。You can update these if you like.

    默认电子邮件设置

  3. 单击或点击“添加操作”。Click or tap Add an Action.

    添加操作

  4. 在“选择操作”下,搜索“SharePoint”,再单击或点击“SharePoint - 更新项”。Under Choose an action, search for "SharePoint", then click or tap SharePoint – Update item.

    “更新项”操作

  5. 输入 SharePoint 网站 URL 和列表名称。Enter the SharePoint site URL and list name.

    “更新项”参数

  6. 选择“ID”框,再单击或点击“动态内容”对话框中的“ID”。Select the Id box, then click or tap ID in the dynamic content dialog box.

    列出 ID 动态内容

  7. 选择“Title”框,在“动态内容”对话框中搜索“Title”,再单击或点击“Title”。Select the Title box, search for "Title" in the dynamic content dialog box, then click or tap Title.

    列出标题动态内容

  8. 在“已批准”框中,输入“否”。In the Approved box, enter "No". 此时,这部分流应如下图所示。This part of the flow should now look like the following image.

    列表更新

  9. 单击或点击屏幕右上角的“创建流”。At the top right of the screen, click or tap Create flow.

    此时,流已创建完成。如果将框折叠起来,应如下图所示。The flow is now complete, and it should look like the following image if you collapse the boxes.

    已完成的流

  10. 单击或点击屏幕右上角的“完成”。At the top right of the screen, click or tap Done.

    “完成”按钮

第 4 步:运行审批流Step 4: Run the approval flow

  1. 在“项目申请”列表中,单击“快速编辑”,并添加一项,如下所示:In the Project Requests list, click Quick Edit and add an item like the following:

    • “Title”的值为“New monitor for Megan”Title = "New monitor for Megan"

    • “Description”的值为“Megan needs a 24" monitor”Description = "Megan needs a 24" monitor"

    • “ProjectType”的值为“New hardware”ProjectType = "New hardware"

    • “RequestDate”的值为“02/03/2017”RequestDate = "02/03/2017"

    • “Requestor”的值为“Megan Bowen”Requestor = "Megan Bowen"

    • “EstimatedDays”的值为“1”EstimatedDays = "1"

    • “Approved”的值为“Pending”Approved = "Pending"

      添加到列表中的项

  2. 完成后,单击网页顶部的“完成”。Click Done at the top of the page when you're finished.

    “完成”复选标记

  3. 检查审批者的电子邮件帐户的收件箱。Check the inbox of the approver's email account. 应收到如下电子邮件。You should have an email like the following.

    向 Allan Deyoung 发送的电子邮件

  4. 单击“批准”或“拒绝”后,此流将运行另一进程,并直接在电子邮件中生成如下反馈。After you click Approve or Reject, the flow runs another process, and you get feedback like the following, directly in the email.

    审批操作已完成

  5. 此流向 Megan 发送包含 Allan 回复的电子邮件,如下图所示。The flow sends an email to Megan with Allan's response, as in the following image. 这封电子邮件的发件人是 Megan,因为她拥有此流。This email comes from Megan because she owns the flow.

    向 Megan Bowen 发送的电子邮件

后续步骤Next steps

本系列教程的下一步是创建用于管理项目的应用The next step in this tutorial series is to create an app to manage projects.