使用 Microsoft Flow 管理顺序审批Manage sequential approvals with Microsoft Flow

有些工作流需要在最后审批者签署之前得到预先批准。Some workflows require pre-approval before the final approver is required to sign off. 例如,一个公司可能有一个顺序审批策略,在得到财务部门批准之前,需要预先批准超过 1000.00 美元的发票。For example, a company may have a sequential approval policy that requires pre-approval for invoices over $1000.00 before they're approved by the Finance department.

在本演练中,我们将创建一个顺序审批流,用于管理员工休假请求。In this walkthrough, we create a sequential approval flow that manages employee vacation requests.

流中的详细步骤Detailed steps in the flow

流:The flow:

  1. 当员工在 SharePoint Online 列表中创建休假请求时启动。Starts when an employee creates vacation request in a SharePoint Online list.

  2. 将休假请求添加到审批中心,并通过电子邮件将请求发送给预审批者。Adds the vacation request to the approval center and then emails the request to the pre-approver.

  3. 将预先批准决策通过电子邮件发送给员工。Emails the pre-approval decision to the employee.

  4. 使用预审批者决策和注释来更新 SharePoint Online 列表。Updates the SharePoint Online list with the pre-approver's decision and comments.

    注意:如果预先批准请求,该流将继续执行以下步骤:Note: If the request is pre-approved, the flow continues with these steps:

  5. 将请求发送给最后审批者。Sends the request to the final approver.

  6. 将最终决策通过电子邮件发送给员工。Emails the final decision to the employee.

  7. 使用最终决策更新 SharePoint 列表。Updates the SharePoint list with the final decision.

此图总结了前面的步骤:This image summarizes the preceding steps:

流的 visio 关系图

先决条件Prerequisites

  • 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 列表必须包含以下列:The SharePoint Online list that you create must include the following columns:

SharePoint 列表列

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

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

  1. 登录到 Microsoft FlowSign into 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.

Sharepoint 信息

获取创建休假请求的人员的管理器。Get the manager for the person who created the vacation request

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

    新建步骤

  2. 将“获取管理器”输入到“选择操作”搜索框。Enter get manager into the Choose an action search box.

  3. 查找并选择“Office 365 用户 - 获取管理器 (V2)”操作。Find, and then select the Office 365 Users - Get manager (V2) action.

    选择 Office 用户

  4. 将“通过电子邮件创建”令牌插入到“获取管理器”卡上的“用户 (UPN)”框中。Insert the Created By Email token into the User (UPN) box on the Get manager card.

    此操作将获取在 SharePoint 中创建休假请求的人员的管理器。This action gets the manager for the person who created the vacation request in SharePoint.

    获取管理器配置

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

    保存流

    备注

    定期从屏幕顶部选择“更新流”以将更改保存到流。Select Update flow from the top of the screen periodically to save the changes to your flow.

    选择更新操作

在执行每个保存操作后,选择屏幕顶部的“编辑流”,然后继续进行更改。After each save operation, select Edit flow from the top of the screen, and then continue making changes.

添加审批操作以用于预先审批Add an approval action for pre-approvals

  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.

    配置审批

注意:此操作会将预先审批请求发送到“分配到”框中的电子邮件地址。Note: This action sends the pre-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:

备注

此条件从“启动审批”操作检查响应。This condition checks the response from the Start an approval action.

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

  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 pre-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.

更新项目配置

获取预审批者的管理器Get the pre-approver's manager

  1. 使用我们前面的获取创建休假请求的人员的管理器步骤来添加并配置另一个“获取管理器”操作。Use the Get the manager for the person who created the vacation request steps we did earlier to add, and then configure another Get manager action. 这次我们将获取预审批者的管理器。This time we get the pre-approver's manager.

  2. 完成后,“获取管理器 2”卡应类似于下图。The Get manager 2 card should resemble this image when you're finished. 请务必使用“从此流中使用的应用和服务中添加动态内容”卡上”获取管理器”类别中的“电子邮件”令牌。Be sure to use the Email token from the Get manager category on the Add dynamic content from the apps and services used in this flow card.

    获取预审批者的管理器

添加最后审批操作Add the final approval action

  1. 使用前面执行的添加审批操作以用于预先审批步骤来添加并配置另一个“启动审批”操作。Use the add an approval action for pre-approvals steps we did earlier to add, and then configure another Start an approval action. 此操作将发送电子邮件请求以进行最后审批。This action sends an email request for final approval.

  2. 完成后,卡应类似于下图:When you're done, the card should resemble this image:

    配置审批

添加最后审批条件Add the final approval condition

  1. 重复添加条件中的步骤,以添加并配置查看最后审批者决策的条件。Repeat the steps from add a condition to add, and then configure a Condition that checks the final approver's decision.

发送最终审批电子邮件Send email with final approval

  1. 使用添加电子邮件操作以用于预先审批中的步骤添加并配置一个操作,以在休假请求得到批准后发送电子邮件。Use the steps from Add an email action for pre-approvals to add, and then configure an action that sends an email when vacation requests are approved.

  2. 完成后,你的卡应类似于下图:When you're finished, your card should resemble this image:

    最终审批电子邮件模板

使用审批更新 SharePointUpdate SharePoint with approval

  1. 使用添加更新操作以用于预先批准请求中的步骤添加并将配置一个操作,以在休假请求得到批准后更新 SharePoint。Use the steps from Add an update action for pre-approved requests to add, and then configure an action that updates SharePoint when the vacation request is approved.

  2. 完成后,卡应类似于下图:When you're finished, the card should resemble this image:

    更新项目配置

发送预先批准拒绝电子邮件Send email with pre-approval rejection

  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.

已拒绝的请求的配置

注意:此操作必须添加到“条件”卡下的“如果否,则不执行任何操作”分支。Note: This action must be added to the IF NO, DO NOTHING branch below the Condition card.

使用预先批准拒绝更新 SharePointUpdate SharePoint with pre-approval rejection

  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.

更新 sharepoint 以用于拒绝的请求

发送最终拒绝电子邮件Send email with final rejection

  1. 使用发送预先批准拒绝电子邮件中的步骤添加并配置一个操作,以在最后审批者拒绝休假请求时发送电子邮件。Use the steps from Send email with pre-approval rejection to add, and then configure an action that sends an email when the vacation request is rejected by the final approver.

    注意:此操作必须添加到“条件 2”卡下的“如果否,则不执行任何操作”分支。Note: This action must be added to the IF NO, DO NOTHING branch below the Condition 2 card.

  2. 完成后,卡应类似于下图:When you're finished, the card should resemble this image:

    已拒绝的请求的配置

使用最终拒绝更新 SharePointUpdate SharePoint with final rejection

  1. 使用使用预先审批拒绝更新 SharePoint 中的步骤添加并配置一个操作,以在最后审批者拒绝休假请求时更新 SharePoint。Use the steps from Update SharePoint with pre-approval rejection to add, and then configure an action that updates SharePoint if the final approver rejects the vacation request.

  2. 完成后,卡应类似于下图:When you're finished, the card should resemble this image:

    更新项目卡

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

    选择更新操作

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

流概览

现在我们已经创建流,我们来看看它的实际效果。Now that we've created the flow, let's see it in action.

请求批准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.

请求应类似于此图像:Your request should resemble this image:

休假请求

查看待审批请求View pending approval requests

通过执行以下步骤来查看所有待审批请求:View all pending approval requests by following these steps:

  1. 登录到 Microsoft FlowSign into Microsoft Flow.

    登录

  2. 选择“审批”选项卡。Select the Approvals tab.

    “审批”选项卡

  3. 查找“已收到请求”下的所有待处理的审批请求。Find all pending approval requests under Received requests.

    待处理的请求

预先批准请求Pre-approve a request

如果你是审批流中的审批者,那么每当有人创建请求时,你都将收到电子邮件。If you're an approver in an approval flow, you receive an email whenever someone creates a request. 审批请求也会发送到审批中心。The approval request is also sent to the approvals center. 然后可以批准或拒绝来自电子邮件、审批中心或 Microsoft Flow 应用的请求。You can then approve or reject requests from the email, the approvals center, or the Microsoft Flow app.

若要批准来自以下各处的请求:To approve a request:

来自电子邮件From email

  1. 当项目添加到 SharePoint Online 列表时,从收到的电子邮件中选择“批准”。Select Approve from the email you receive when an item is added to the SharePoint Online list.

    注意:如果使用的是安装了 Microsoft Flow 应用的移动设备,则会启动 Microsoft Flow 应用,否则会在浏览器中打开审批中心。Note: If you're using a mobile device with the Microsoft Flow app installed, the Microsoft Flow app launches, otherwise, the approvals center opens in your browser.

    请求电子邮件

  2. 输入注释,然后选择“确认”按钮。Enter a comment, and then select the Confirm button.

    输入注释

来自审批中心From the approvals center

  1. 登录到 Microsoft FlowSign into Microsoft Flow.

    登录

  2. 选择“审批”选项卡。Select the Approvals tab.

    从空白创建

  3. 在想要批准的请求上选择“批准”。Select Approve on the request you want to approve.

    从空白创建

  4. 添加备注,然后选择“确认”按钮。Add a note, and then select the Confirm button.

    添加备注,然后确认

来自 Microsoft Flow 应用From the Microsoft Flow app

  1. 在安装了 Microsoft Flow 应用的移动电话上,从请求审批电子邮件中选择“批准”。On your mobile phone with the Microsoft Flow app installed, select Approve from the request approval email.

  2. 在屏幕右上角选择“确认”。Select Confirm in the upper right corner of the screen.

    选择“确认”

  3. 此时将显示“成功”页,指示已记录你的审批。The success page shows, indicating that your approval has been recorded.

    “成功”页

注意:Android、iOS 和 Windows Phone 上的屏幕可能略有不同,但所有设备上的功能是相同的。Note: The screens on Android, iOS and Windows Phone may differ slightly, however, the functionality is the same on all devices.

批准请求Approve the request

批准请求的步骤与预先批准请求的步骤相同The steps to approve a request are identical to the steps to pre-approve a request

注意:最后审批者只有在请求得到预先批准后才能获取休假请求。Note: The final approver gets the vacation request only after the request has been pre-approved.

拒绝请求Reject a request

可以通过电子邮件、审批中心或 Microsoft Flow 应用拒绝请求。You can reject a request via email, the approvals center, or the Microsoft Flow app. 若要拒绝请求,请执行用于审批请求的步骤,但选择“拒绝”,而不是“批准”。To reject a request, follow the steps for approving a request, but select Reject, instead of Approve.

在你确认决策(拒绝请求)之后,流将运行以下步骤:After you confirm your decision (rejection of the request), the flow runs the following steps:

  1. 将一封电子邮件发送给请求休假的人员。Sends an email to the person who requested vacation.
  2. 使用该决策以及来自审批者的注释更新 SharePoint Online 列表。Updates the SharePoint Online list with the decision, and the comments from the approver.

详细信息More information

单个审批者现代审批演练Single approver modern approvals walkthrough