培训
认证
Microsoft Certified: Power Automate RPA Developer Associate - Certifications
演示如何与 Microsoft Power Automate RPA 开发人员一起改进和自动化工作流。
在此方案中,你是一名人力资源招聘人员,在 Teams 中安排与候选人的面试会议。 在 Excel 文件中管理候选人的面试日程。 你需要将 Teams 会议邀请发送给候选人和面试官。 然后,需要更新 Excel 文件,确认 Teams 会议已发送。
该解决方案有三个步骤,这些步骤合并到单个 Power Automate 流中。
有关使用 JSON 的详细信息,请阅读 使用 JSON 将数据传入 Office 脚本和从 Office 脚本传递数据。
将示例工作簿下载到 OneDrive。
在 Excel 中打开工作簿。
将至少一个电子邮件地址更改为你自己的电子邮件地址,以便接收邀请。
function main(workbook: ExcelScript.Workbook): InterviewInvite[] {
const MEETING_DURATION = workbook.getWorksheet("Constants").getRange("B1").getValue() as number;
const MESSAGE_TEMPLATE = workbook.getWorksheet("Constants").getRange("B2").getValue() as string;
// Get the interview candidate information.
const sheet = workbook.getWorksheet("Interviews");
const table = sheet.getTables()[0];
const dataRows = table.getRangeBetweenHeaderAndTotal().getValues();
// Convert the table rows into InterviewInvite objects for the flow.
let invites: InterviewInvite[] = [];
dataRows.forEach((row) => {
const inviteSent = row[1] as boolean;
if (!inviteSent) {
const startTime = new Date(Math.round(((row[6] as number) - 25569) * 86400 * 1000));
const finishTime = new Date(startTime.getTime() + MEETING_DURATION * 60 * 1000);
const candidateName = row[2] as string;
const interviewerName = row[4] as string;
invites.push({
ID: row[0] as string,
Candidate: candidateName,
CandidateEmail: row[3] as string,
Interviewer: row[4] as string,
InterviewerEmail: row[5] as string,
StartTime: startTime.toISOString(),
FinishTime: finishTime.toISOString(),
Message: generateInviteMessage(MESSAGE_TEMPLATE, candidateName, interviewerName)
});
}
});
console.log(JSON.stringify(invites));
return invites;
}
function generateInviteMessage(
messageTemplate: string,
candidate: string,
interviewer: string) : string {
return messageTemplate.replace("_Candidate_", candidate).replace("_Interviewer_", interviewer);
}
// The interview invite information.
interface InterviewInvite {
ID: string
Candidate: string
CandidateEmail: string
Interviewer: string
InterviewerEmail: string
StartTime: string
FinishTime: string
Message: string
}
将脚本命名为流的 “计划采访 ”。
使用以下代码创建另一个新脚本。 这会将行标记为已邀请。
function main(workbook: ExcelScript.Workbook, invites: InterviewInvite[]) {
const table = workbook.getWorksheet("Interviews").getTables()[0];
// Get the ID and Invite Sent columns from the table.
const idColumn = table.getColumnByName("ID");
const idRange = idColumn.getRangeBetweenHeaderAndTotal().getValues();
const inviteSentColumn = table.getColumnByName("Invite Sent?");
const dataRowCount = idRange.length;
// Find matching IDs to mark the correct row.
for (let row = 0; row < dataRowCount; row++){
let inviteSent = invites.find((invite) => {
return invite.ID == idRange[row][0] as string;
});
if (inviteSent) {
inviteSentColumn.getRangeBetweenHeaderAndTotal().getCell(row, 0).setValue(true);
console.log(`Invite for ${inviteSent.Candidate} has been sent.`);
}
}
}
// The interview invite information.
interface InterviewInvite {
ID: string
Candidate: string
CandidateEmail: string
Interviewer: string
InterviewerEmail: string
StartTime: string
FinishTime: string
Message: string
}
此流运行面试计划脚本、发送 Teams 会议,并将活动记录回工作簿中。
创建新的 即时云流。
选择 “手动触发流 ”,然后选择“ 创建”。
在流生成器中 + ,选择按钮和 “添加操作”。 使用 Excel Online (Business) 连接器的 “运行脚本” 操作。 使用以下值完成操作。
添加使用 Microsoft Teams 连接器的 “创建 Teams 会议 ”操作的操作。 从 Excel 连接器中选择动态内容时,将为流生成 For each 块。 使用以下值完成连接器。
在同一个 For each 块中,添加另一个 “运行脚本” 操作。 使用以下值。
保存流。 流设计器应如下图所示。
使用流编辑器页上的“ 测试 ”按钮,或通过“我的流”选项卡运行 流 。请务必在出现提示时允许访问。
观看 Sudhi Ramamurthy 在 YouTube 上演练此示例的一个版本。 他的版本使用更可靠的脚本来处理更改列和过时的会议时间。
培训
认证
Microsoft Certified: Power Automate RPA Developer Associate - Certifications
演示如何与 Microsoft Power Automate RPA 开发人员一起改进和自动化工作流。