Power Automate 示例
下面每个示例都是一个 Power Automate 云端流:一个 Microsoft 触发器,生成文档的 AutomaDoc 步骤,以及交付文档的 Microsoft 步骤。这些示例假定您已添加 AutomaDoc 连接器并建立了连接;如果还没有,请参见 Power Automate 和 Power Apps。
三个示例都使用同样的两个 AutomaDoc 操作:
| 操作 | 需要填写的内容 | 提供给后续步骤的内容 |
|---|---|---|
| Generate a document | Template(从列表中选择),然后是该模板每个占位符对应的输入项,以及 Output Format(pdf、png 或 native;留空表示使用模板的设置) |
Document ID、File Name、Status、Download URL、Warnings |
| Download document | Document ID ← Generate a document 输出的 Document ID |
File Content |
Generate a document 会等到文档就绪;文档无法生成时,它会失败并给出原因。File Name Pattern 和 Record ID 位于其高级参数中。
请某人审批一个请求,只在对方批准时才生成文档:采购订单、请假证明、已确认的报价单。
触发器。 任何发起请求的方式。对于提交到 SharePoint 列表中的请求,使用 SharePoint → When an item is created;如需手动发起,使用 Manually trigger a flow 并添加所需的输入。
步骤。
- Approvals → Start and wait for an approval。
- Approval type:Approve/Reject - First to respond。
- Title、Assigned to 和 Details:来自触发器,例如 Title 和审批人的邮箱地址。
- Control → Condition:
Outcome(来自 Start and wait for an approval)is equal toApprove。 - 在 True 分支中添加 AutomaDoc → Generate a document:
- Template:您的采购订单模板。
- 用触发器的动态内容(Title、Amount、Supplier 等)映射模板的输入项,审批相关的输入则来自 Start and wait for an approval:
Outcome、Response summary、Completion date。 - Output Format:
pdf。
- 添加 AutomaDoc → Download document,其中 Document ID ←
Document ID。 - 交付文档,以下任选其一或两者都用:
- Office 365 Outlook → Send an email (V2):To 填写请求人;在 Attachments 下,Attachments Name ←
File Name,Attachments Content ←File Content。 - SharePoint → Create file:您文档库的 Site Address 和 Folder Path,File Name ←
File Name,File Content ←File Content。
- Office 365 Outlook → Send an email (V2):To 填写请求人;在 Attachments 下,Attachments Name ←
需要映射的动态内容。
| 模板输入项 | 动态内容 |
|---|---|
Request |
Title(触发器) |
Amount、Supplier |
请求自己的列(触发器) |
Decision |
Outcome |
Approval_note |
Response summary |
Approved_on |
Completion date |
Responses Approver name 和 Responses Comments 来自一个每位审批人一项的列表,因此使用它们时,Power Automate 会把该步骤放进 Apply to each,结果是每位审批人生成一份文档。如果要每个请求只生成一份文档,请改用 Response summary。
计数方式。 每个获批的请求一份文档。被拒绝的请求进入 False 分支,不产生任何费用。
收到 Microsoft Forms 回复时
Section titled “收到 Microsoft Forms 回复时”把每条表单回复变成一份文档,并发回给填写人:报名确认、询价请求、检查报告。
触发器。 Microsoft Forms → When a new response is submitted,在 Form Id 中选择您的表单。
步骤。
- Microsoft Forms → Get response details:同样的 Form Id,Response Id ← 触发器输出的
Response Id。 - AutomaDoc → Generate a document:
- Template:您的确认模板。
- 用 Get response details 映射每个输入项:每个问题都以其标题作为动态内容出现。
- Output Format:
pdf。
- 添加 AutomaDoc → Download document,其中 Document ID ←
Document ID。 - Office 365 Outlook → Send an email (V2):To ←
Responders' Email;Attachments Name ←File Name,Attachments Content ←File Content。
需要映射的动态内容。
| 模板输入项 | 动态内容(Get response details) |
|---|---|
Name、Company、Date |
同名的问题 |
Email |
Responders' Email |
Submitted |
Submission time |
- 只有当表单记录填写人身份时(面向组织内部人员的表单),
Responders' Email才有值。对于任何人都能填写的表单,请添加一个询问邮箱地址的问题,并发送到该答案。 - 允许多个答案的问题会把答案作为一段带方括号的文本给出,例如
["Red","Blue"],模板也会照此打印。如果想打印成Red, Blue,请用表达式join(json(<the answer>), ', ')填充该输入项。 - 通过表单上传的文件存储在需要登录的 OneDrive 或 SharePoint 中,因此无法填充占位图片:图片输入必须是公开的网址(
https://或http://)。
计数方式。 每条回复一份文档。
创建 SharePoint 列表项时
Section titled “创建 SharePoint 列表项时”根据新列表项的列生成文档,然后把文档保存在列表项旁边:保存到文档库,或作为该列表项自己的附件。
触发器。 SharePoint → When an item is created,填写您的 Site Address 和 List Name。
步骤。
- AutomaDoc → Generate a document:
- Template:您的模板。
- 用触发器的列映射每个输入项。
- Output Format:
pdf。
- 添加 AutomaDoc → Download document,其中 Document ID ←
Document ID。 - 保存文件,以下任选其一:
- SharePoint → Create file:Site Address、Folder Path(例如
/Shared Documents/Contracts)、File Name ←File Name、File Content ←File Content。 - SharePoint → Add attachment:与触发器相同的 Site Address 和 List Name,Id ← 触发器输出的
ID,File Name ←File Name,File Content ←File Content。
- SharePoint → Create file:Site Address、Folder Path(例如
需要映射的动态内容。
| 列类型 | 使用的动态内容 |
|---|---|
| 文本、数字、日期 | 该列本身 |
| 选项 | 列名 Value |
| 个人 | 列名 DisplayName(或 Email) |
| 查阅 | 列名 Value |
把触发器的 ID 映射到 Generate a document 高级参数中的 Record ID,这样 {Record_ID} 就会打印列表项的编号。
- 请使用 When an item is created,而不是 When an item is created or modified:添加附件会修改列表项,从而再次启动流。
- 一次导入大量列表项时,每项都会启动一次流。单个模板每分钟超过 60 个请求时,该步骤会返回
429,由 Power Automate 的重试策略再次尝试。 - 要用多个列表项生成一份文档(对账单、列表、标签),请参见多行合成一份文档。
计数方式。 每个新列表项一份文档。