通过 Microsoft Flow 创建和测试审批工作流Create and test an approval workflow with Microsoft Flow

使用 Microsoft Flow 可以跨多个服务管理文档或流程的审批,这些服务包括:SharePoint、Dynamics CRM、Salesforce、OneDrive for Business、Zendesk 或 WordPress。With Microsoft Flow, you can manage the approval of documents or processes across several services, including SharePoint, Dynamics CRM, Salesforce, OneDrive for Business, Zendesk, or WordPress.

若要创建审批工作流,请向任意流添加“审批 - 启动审批”操作。To create an approval workflow, add the Approvals - Start an approval action to any flow. 添加此操作后,即可通过流来管理文档或流程的审批。After you add this action, your flow can manage the approval of documents or processes. 例如,可以创建文档审批流来审批发票、工作订单或销售报价单。For example, you can create document approval flows that approve invoices, work orders, or sales quotations. 还可以创建流程审批流来审批休假请求、加班或旅行计划。You can also create process approval flows that approve vacation requests, overtime work, or travel plans.

审批者可以回复来自其电子邮件收件箱、Microsoft Flow 网站上的审批中心或 Microsoft Flow 应用的请求。Approvers can respond to requests from their email inbox, the approvals center on the Microsoft Flow website, or the Microsoft Flow app.

创建审批流Create an approval flow

下面是我们将创建和测试的流的概览:Here's an overview of the flow we'll create and test:

流概览

流执行以下步骤:The flow performs the following steps:

  1. 当某人在 SharePoint Online 列表中创建休假请求时启动。Starts when someone creates a vacation request in a SharePoint Online list.
  2. 将休假请求添加到审批中心,并通过电子邮件将其发送给审批者。Adds the vacation request to the approval center, and then emails it to the approver.
  3. 将一封电子邮件连同审批者的决定发送给请求休假的人员。Sends an email with the approver's decision to the person who requested vacation.
  4. 使用审批者的决策注释更新 SharePoint Online 列表。Updates the SharePoint Online list with the approver's decision comments.

先决条件Prerequisites

若要完成本演练,你必须有执行以下操作所需的访问权限:To complete this walkthrough, you must have access to:

  • Microsoft FlowMicrosoft Flow.
  • SharePoint Online 列表。A SharePoint Online list.
  • Office 365 Outlook 和 Office 365 用户帐户。Office 365 Outlook and Office 365 Users account.

备注

虽然我们在本演练中使用 SharePoint Online 和 Office 365 Outlook,但你可以使用 Zendesk、Salesforce 或 Gmail 等其他服务。While we use SharePoint Online and Office 365 Outlook in this walk-through, you can use other services such as Zendesk, Salesforce, or Gmail.

创建流之前,请创建 SharePoint Online 列表;稍后,我们将使用此列表来请求批准休假。Before you create the flow, create a SharePoint Online list; later, we'll use this list to request approval for vacations.

在 SharePoint Online 列表中创建以下列:Create these columns in your SharePoint Online list:

SharePoint Online 列表列

请记下 SharePoint Online 列表的名称和 URL。Make note of the name and URL of the SharePoint Online list. 稍后在配置“SharePoint - 当创建项时”触发器时,将需使用这些项。You'll need these items later when you configure the SharePoint - When an item is created trigger.

从空白模板创建流Create your flow from the blank template

  1. 登录到 Microsoft FlowSign in to Microsoft Flow.

    登录

  2. 选择“我的流”选项卡。Select the My flows tab.

    选择我的流

  3. 选择“从零开始创建”。Select Create from blank.

    从空白创建

  4. 选择“从零开始创建”按钮。Select the Create from blank button.

添加触发器Add a trigger

  1. 将“Sharepoint”输入到搜索框中。Enter SharePoint into the search box.

    搜索 Sharepoint 触发器

  2. 查找并选择“SharePoint - 当创建项时”触发器。Find, and then select the SharePoint - When an item is created trigger.

    选择 Sharepoint 触发器

  3. 为 SharePoint 列表(你的流监视该列表的新项)选择站点地址列表名称Select the Site Address and the List Name for the SharePoint list that your flow monitors for new items.

“站点地址”和“列表名称”是你在本演练中的前面部分记下的项。The Site Address and the List Name are the items you noted earlier in this walkthrough.

Sharepoint 信息

添加“配置文件”操作Add a profile action

  1. 选择“新建步骤”,然后选择“添加操作”。Select New step, and then select Add an action.

    新建步骤

  2. 将“配置文件”输入到“选择操作”搜索框。Enter profile into the Choose an action search box.

    搜索配置文件

  3. 查找并选择“Office 365 用户 - 获取我的配置文件”操作。Find, and then select the Office 365 Users - Get my profile action.

    选择 Office 用户

  4. 为你的流提供一个名称,然后选择“创建流”保存目前为止已进行的工作。Provide a name for your flow, and then select Create flow to save the work we've done so far.

    保存流

添加“审批”操作Add an approval action

  1. 选择“新建步骤”,然后选择“添加操作”。Select New step, and then select Add an action.

    新建步骤

  2. 将“审批”输入到“选择操作”搜索框。Enter approval into the Choose an action search box.

    搜索审批

  3. 选择“审批 - 启动审批”操作。Select the Approvals - Start an approval action.

    选择“审批”操作

  4. 配置“启动审批”卡以适合你的需求。Configure the Start an approval card to suit your needs.

    备注

    “标题”和“分配到”是必填字段。The Title and Assigned To fields are required. 可以使用 Markdown 设置“详细信息”字段的格式。You can use Markdown to format the Details field.

    配置审批

备注

此操作会将审批请求发送至“分配到”框中的电子邮件地址。This action sends the approval request to the email address in the Assigned To box.

添加条件Add a condition

  1. 选择“新建步骤”,然后选择“添加条件”。Select New step, and then select Add a condition.

    添加条件

  2. 选择“对象名称”框,然后将“响应”输入到“从此流中使用的应用和服务中添加动态内容”卡上的搜索框中。Select the Object Name box, and then enter response into the search box on the Add dynamic content from the apps and services used in this flow card.

  3. 选择“响应”标记。Select the Response token.

    选择“响应”标记

  4. 选择“值”框,然后将“批准”输入到框中。Select the Value box, and then enter Approve into the box.

    备注

    对“审批 - 启动审批”操作的有效响应为“批准”和“拒绝”。The valid responses to the Approvals - Start an approval action are "Approve" and "Reject". 这些响应区分大小写。These responses are case-sensitive.

  5. “条件”卡现在应类似于此图像:Your Condition card should now resemble this image:

添加电子邮件操作以用于审批Add an email action for approvals

如果休假请求已经被批准,请按照下列步骤发送一封电子邮件:Follow these steps to send an email if the vacation request is approved:

  1. 选择该条件的“如果是”分支上的“添加操作”。Select Add an action on the IF YES branch of the condition.

    添加新步骤

  2. 将“发送电子邮件”输入到“选择操作”卡上的搜索框中。Enter send email into the search box on the Choose an action card.

    搜索电子邮件操作

  3. 选择“Office 365 Outlook - 发送电子邮件”操作。Select the Office 365 Outlook - Send an email action.

    选择“发送电子邮件”操作

  4. 配置“电子邮件”卡以适合你的需求。Configure the email card to suit your needs.

    备注

    “收件人”、“主题”和“正文”是必填字段。To, Subject, and Body are required.

    此卡是休假请求状态更改时发送的电子邮件的模板。This card is a template for the email that is sent when the status of the vacation request changes.

    注意:在“发送电子邮件”卡上的“正文”框中,请使用来自“审批 - 启动审批”操作的“注释”标记。Note: In the Body box on the Send an email card, use the Comments token from the Approvals - Start an approval action.

配置已批准的电子邮件模板

添加用于已批准请求的更新操作Add an update action for approved requests

  1. 在“如果是”分支中,选择“添加操作”。Select Add an action from the IF YES branch.

  2. 将“更新”输入到“选择操作”卡上的搜索框中。Enter update into the search box on the Choose an action card.

    搜索“更新”操作

  3. 选择“SharePoint - 更新项目”操作。Select the SharePoint - Update item action.

    选择更新项目

  4. 配置“更新项目”卡以适合你的需求。Configure the Update item card to suit your needs.

备注

“站点地址”、“列表名称”、“ID”和“标题”是必填项。Site Address, List Name, Id, and Title are required.

更新项目配置

添加电子邮件操作以用于拒绝Add an email action for rejections

  1. 选择“如果否,则不执行任何操作”分支上的“添加操作”。Select Add an action on the IF NO, DO NOTHING branch.

  2. 将“发送电子邮件”输入到“选择操作”卡的搜索框中。Enter Send email into the search box of the Choose an action card.

    搜索电子邮件操作

  3. 选择“Office 365 Outlook - 发送电子邮件”操作。Select the Office 365 Outlook - Send an email action.

    选择“发送电子邮件”操作

  4. 配置“电子邮件”卡以适合你的需求。Configure the email card to suit your needs.

    此卡表示休假请求状态更改时发送的电子邮件的模板。This card represents the template for the email that's sent when the status of vacation requests change.

已拒绝的请求的配置

添加用于已拒绝请求的更新操作Add update action for rejected requests

  1. 选择“添加操作”。Select Add an action.

    添加操作

  2. 将“更新项目”输入到“选择操作”卡上的搜索框中。Enter update item into the search box on the Choose an action card.

    搜索“更新”操作

  3. 选择“SharePoint - 更新项目”操作。Select the SharePoint - Update item action.

    选择更新项目

  4. 配置卡以适合你的需求。Configure the card to suit your needs.

备注

“站点地址”、“列表名称”、“ID”和“标题”是必填项。Site Address, List Name, Id, and Title are required.

更新项目卡

  1. 选择“更新流”以保存已完成的工作。Select Update flow to save the work we've done.

    选择更新操作

如果已按照上述步骤执行操作,流应类似于此屏幕截图:If you've followed along, your flow should resemble this screenshot:

流概览

既然已创建了流,现在就要对其进行测试了!Now that we've created the flow, it's time to test it!

请求批准Request an approval

在前面创建的 SharePoint Online 列表中创建休假请求。Create a vacation request in the SharePoint Online list you created earlier.

保存此请求、流触发器之后:After you save this request, the flow triggers, and then:

  1. 在审批中心创建一个请求。Creates a request in the approvals center.
  2. 将审批请求通过电子邮件发送到审批者。Sends an approval request email to the approvers.

创建并测试流以后,请务必让他人知道如何使用该流。Now that you've created and tested your flow, be sure to let others know how to use it.

了解详情Learn more