如何修复Power Automate中实习生入职测验邮件自动化重复发送问题
Power Automate实习生入职测验提醒逻辑优化问题
我们通过Power Automate搭建了实习生入职测验提醒工作流:每隔数日向未完成入职测验的实习生发送提醒邮件,工作流会读取存储实习生信息的Microsoft List数据,当前以OrientationStartDate为空作为发送提醒的判断条件。但实际运行中发现,实习生完成测验后仍会收到提醒邮件,判断逻辑存在问题。
附Microsoft List返回的JSON数据:
{ "statusCode": 200, "headers": { "Transfer-Encoding": "chunked", "Vary": "Origin,Accept-Encoding", "X-NetworkStatistics": "1,4204800,0,16,64507,0,35062", "X-SharePointHealthScore": "3", "X-MS-SPConnector": "1", "X-SP-SERVERSTATE": "ReadOnly=0", "DATASERVICEVERSION": "3.0", "SPClientServiceRequestDuration": "48", "SPRequestDuration": "49", "X-DataBoundary": "NONE", "X-1DSCollectorUrl": "https://mobile.events.data.microsoft.com/OneCollector/1.0/", "X-AriaCollectorURL": "https://browser.pipe.aria.microsoft.com/Collector/3.0/", "SPRequestGuid": "ea07e98b-d1a0-480b-8c95-ffac44956acc", "request-id": "ea07e98b-d1a0-480b-8c95-ffac44956acc", "MS-CV": "i+kH6qDRC0iMlf+sRJVqzA.0", "Strict-Transport-Security": "max-age=31536000", "X-FRAME-OPTIONS": "SAMEORIGIN", "Content-Security-Policy": "frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.office.com *.stream.azure-test.net *.microsoftstream.com *.dynamics.com *.microsoft.com onedrive.live.com *.onedrive.live.com securebroker.sharepointonline.com;", "MicrosoftSharePointTeamServices": "16.0.0.23717", "X-Content-Type-Options": "nosniff", "X-MS-InvokeApp": "1; RequireReadOnly", "Timing-Allow-Origin": "*", "x-ms-apihub-cached-response": "true", "x-ms-apihub-obo": "false", "Cache-Control": "max-age=0, private", "Date": "Fri, 02 Jun 2023 05:02:47 GMT", "P3P": "CP=\"ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI\"", "X-AspNet-Version": "4.0.30319", "X-Powered-By": "ASP.NET", "Content-Type": "application/json; charset=utf-8", "Expires": "Thu, 18 May 2023 05:02:47 GMT", "Last-Modified": "Fri, 02 Jun 2023 05:02:47 GMT", "Content-Length": "2362" }, "body": { "value": [ { "@odata.etag": "\"1\"", "ItemInternalId": "1", "ID": 1, "Title": "Harry", "LastName": "Potter", "InternEmail": "real@email.com", "Active": { "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", "Id": 1, "Value": "active" }, "Active#Id": 1, "SchoolEmail": " real@email.com", "StartDate": "2023-06-01", "OrientationEndDate": "2023-06-08", "OData__x0034__x002e_5CheckStartDate": "2023-06-01", "OrentationSentDate": "2023-05-25T07:00:00Z", "OrientationStartDate": "2023-06-01T07:00:00Z", "OrientationCheckin": "2023-05-25", "OrientationCheck": "Yes", "OData__x0034__x002e_5QuizReadytobeSent": "No", "RTG": { "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", "Id": 0, "Value": "R" }, "RTG#Id": 0, "Created": "2023-06-02T01:22:55Z", "Author": { "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser", "Claims": "i:0#.f|membership|fake@fake.com", "DisplayName": "person", "Email": " fake@fake.com ", "Picture": "https://greentreechina.sharepoint.com/sites/GreentreeHR/_layouts/15/UserPhoto.aspx?Size=L&AccountName=fake@fake.com", "Department": null, "JobTitle": null }, "Author#Claims": "i:0#.f|membership| fake@fake.com ", "DeleteIntern_x003f_": false, "Modified": "2023-06-02T01:22:55Z", "Editor": { "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser", "Claims": "i:0#.f|membership|andrewisaacrosenthal@greentree.group", "DisplayName": "Andrew Isaac Rosenthal", "Email": " fake@fake.com ", "Picture": "https://greentreechina.sharepoint.com/sites/GreentreeHR/_layouts/15/UserPhoto.aspx?Size=L&AccountName= fake@fake.com", "Department": null, "JobTitle": null }, "Editor#Claims": "i:0#.f|membership|fake@fake.com", "TeamEmail": " fake@fake.com ", "SGReminderTimes": 0.0, "{Identifier}": "Lists%252fMyTest%252f1_.000", "{IsFolder}": false, "{Thumbnail}": { "Large": null, "Medium": null, "Small": null }, "{Link}": "https://greentreechina.sharepoint.com/sites/GreentreeHR/_layouts/15/listform.aspx?PageType=4&ListId=82119073%2D3cdb%2D49d2%2Dace1%2D7065d2009a53&ID=1&ContentTypeID=0x0100F358CD037A56064EB15A0470DF8C2D5C", "{Name}": "Harry", "{FilenameWithExtension}": "Harry", "{Path}": "Lists/MyTest/", "{FullPath}": "Lists/MyTest/1_.000", "{HasAttachments}": false, "{VersionNumber}": "1.0" } ] } }
问题分析
从返回的JSON数据可观察到:已完成测验的实习生(OrientationCheck为"Yes"),OrientationStartDate字段存在有效值(2023-06-01T07:00:00Z),但当前逻辑仍触发提醒,可能的原因包括:
- 实习生完成测验后,
OrientationStartDate字段未按预期更新(比如未被置空或标记为完成状态); - 工作流仅依赖
OrientationStartDate为空的判断,未结合直接标记测验完成状态的OrientationCheck字段,存在逻辑漏洞; - 字段名称拼写错误:JSON中存在
OrentationSentDate(缺少字母i),若工作流中引用字段时出现拼写错误,会导致判断条件失效。
优化方案
方案1:结合OrientationCheck状态判断
利用OrientationCheck字段直接标记测验完成状态的特性,将判断条件调整为:
OrientationCheck不等于 "Yes"- 同时增加时间范围校验(比如当前日期不早于实习生入职
StartDate,避免提前发送)
Power Automate中的条件表达式示例:
And( not(equals(items('Apply_to_each')?['OrientationCheck'], 'Yes')), greaterOrEquals(utcNow(), items('Apply_to_each')?['StartDate']) )
方案2:修正字段引用与更新逻辑
- 检查工作流中引用的字段名称是否准确,确认是否混淆了
OrientationStartDate与拼写错误的OrentationSentDate; - 验证实习生完成测验时的触发动作,确保
OrientationCheck或OrientationStartDate字段被正确更新,实现状态同步。
方案3:增加提醒次数限制
结合SGReminderTimes字段设置提醒次数上限(比如最多发送3次),避免无限循环发送:
- 条件中增加
SGReminderTimes小于 3; - 每次发送提醒后,执行更新操作将
SGReminderTimes字段值+1。
内容的提问来源于stack exchange,提问作者ProgrammerNoob
相关产品推荐
相关产品推荐

