admin管理员组文章数量:1122832
Thanks in advance to whomever takes the time to read and assist!
Ok I am trying to build this flow to send onboarding emails to employees. What it is supposed to do is check through a sharepoint list and see:
- Who needs to receive a reminder email today
- Which reminder needs to be sent.
- Pull in first name to add into the email subject line and text
- Accounting for the employee's start date, set the date for the next reminder according to a given time interval
- Repeat this until the employees cycle out of the sequence. I have the contact data in a sharepoint list and the list contains the following information: User Name (email) First name Last name Email address Employee Communication Language Manager Email Manager communication language Start date Next reminder date Reminder status Birthday Email Opt in Years of service I have the following flow steps and I need debugging help:
- A "recurrence", step which for testing runs every 10 mins, but in reality would run once a day.
- A "get items" step which references the Sharepoint list. And then has the following “filter query” NextReminderDate ge '@{formatDateTime(utcNow(), 'yyyy-MM-dd')}T00:00:00Z' and NextReminderDate lt '@{formatDateTime(addDays(utcNow(), 1), 'yyyy-MM-dd')}T00:00:00Z'
- A “Filter array” step which, in advanced mode, has the following inputs: From: "@outputs('Get_items')?['body/value']" Where: @and( greaterOrEquals( formatDateTime(convertTimeZone(item()?['NextReminderDate'], 'UTC', 'Eastern Standard Time'), 'yyyy-MM-ddTHH:mm'), formatDateTime(convertTimeZone(addMinutes(utcNow(), -1), 'UTC', 'Eastern Standard Time'), 'yyyy-MM-ddTHH:mm') ), lessOrEquals( formatDateTime(convertTimeZone(item()?['NextReminderDate'], 'UTC', 'Eastern Standard Time'), 'yyyy-MM-ddTHH:mm'), formatDateTime(convertTimeZone(addMinutes(utcNow(), 1), 'UTC', 'Eastern Standard Time'), 'yyyy-MM-ddTHH:mm') ) )
- A “Compose” step for debugging whose input is: @{outputs('Filter_array')
- An "Apply to each" called “Apply to Each 5” who is referencing this output: @{body('Filter_array')?['body'] Nested within this is another “Apply to each” called “Apply to each” which loops on @{items('Apply_to_each_5')
Nested within this is another “Apply to each” called “First day email” and this is looping on @{items('Apply_to_each')}
Within “First day email” there is a “Switch” and in the “On” field: @{items('First_Day_Email')?['ReminderStatus/Value']} The “Case” is: Equals “First Day” Then there is a “Condition”: items(‘First_Day_Email’)?[EmployeeCommunicationLanguage/Value’] contains “English” This then sends the appropriate email, either English and French using a "Send an Email V2" to send the English "First Day" email (if no it sends a French version) and then updates the sharepoint list items involved so that the "Next Reminder Date" is a set to a number of days as determined by this expression: @{addDays(items('First_day_email')?['StartDate'], X)} where X is the number of days after the start date that the next reminder should be sent. it also updates the Reminder Status Value to "Two Months" so it knows that when it comes time to send this contact a reminder email that it's the correct email. The flow continues and does basically the same kind of thing as in point 5 in this bullet list for Reminder Status value 2 Months, a manager reminder email, and then Three Months. 4 emails in total.
Here's the thing, when doing this, I ALWAYS get an error at the start of step 5 in this bullet list: The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each_5')' is of type 'Object'. The result must be a valid array.
I am trying to troubleshoot this and can't get far.
Checking Compose output shows this (some item data modded for security):
{
"body": [
{
"@odata.etag": "\"321\"",
"ItemInternalId": "26",
"ID": 26,
"UserName": "[email protected]",
"FirstName": "John",
"LastName": "Doe",
"EmailAddress": "[email protected]",
"EmployeeCommunicationLanguage": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 0,
"Value": "English"
},
"EmployeeCommunicationLanguage#Id": 0,
"ManagerEmail": "[email protected]",
"ManagerCommunicationLanguage": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 0,
"Value": "English"
},
"ManagerCommunicationLanguage#Id": 0,
"StartDate": "2024-11-21T14:30:00Z",
"NextReminderDate": "2024-11-21T14:30:00Z",
"ReminderStatus": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 0,
"Value": "First Day"
},
"ReminderStatus#Id": 0,
"Birthday": "2024-10-10",
"EmailOptIn": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 0,
"Value": "Yes"
},
"EmailOptIn#Id": 0,
"YearsOfService": 0,
"Modified": "2024-11-21T14:26:52Z",
"Created": "2024-04-22T02:23:07Z",
"Author": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
"Claims": "i:0#.f|membership|[email protected]",
"DisplayName": "Johnny Doe",
"Email": "[email protected]",
"Picture": ".aspx?Size=L&[email protected]",
"Department": "Marketing",
"JobTitle": "Marketing Manager"
},
"Author#Claims": "i:0#.f|membership|[email protected]",
"Editor": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
"Claims": "i:0#.f|membership|[email protected]",
"DisplayName": "Johnny Doe",
"Email": "[email protected]",
"Picture": ".aspx?Size=L&[email protected]",
"Department": "Marketing",
"JobTitle": "Marketing Manager"
},
"Editor#Claims": "i:0#.f|membership|[email protected]",
"{Identifier}": "Lists%252fTest%2bHR%2bMailing%2bDB%252f26_.000",
"{IsFolder}": false,
"{Thumbnail}": {
"Large": null,
"Medium": null,
"Small": null
},
"{Link}": ".aspx?PageType=4&ListId=f005fd8d%2D3901%2D474a%2Dbe7a%2D3cdbd4fbd149&ID=26&ContentTypeID=0x0100EB5F7FD3E55DCC4CA6D5F13E31528A90001D414B65A006B34A9D620F2505659474",
"{Name}": "",
"{FilenameWithExtension}": "",
"{Path}": "Lists/Test HR Mailing DB/",
"{FullPath}": "Lists/Test HR Mailing DB/26_.000",
"{HasAttachments}": false,
"{VersionNumber}": "321.0"
}
]
}
Thanks in advance to whomever takes the time to read and assist!
Ok I am trying to build this flow to send onboarding emails to employees. What it is supposed to do is check through a sharepoint list and see:
- Who needs to receive a reminder email today
- Which reminder needs to be sent.
- Pull in first name to add into the email subject line and text
- Accounting for the employee's start date, set the date for the next reminder according to a given time interval
- Repeat this until the employees cycle out of the sequence. I have the contact data in a sharepoint list and the list contains the following information: User Name (email) First name Last name Email address Employee Communication Language Manager Email Manager communication language Start date Next reminder date Reminder status Birthday Email Opt in Years of service I have the following flow steps and I need debugging help:
- A "recurrence", step which for testing runs every 10 mins, but in reality would run once a day.
- A "get items" step which references the Sharepoint list. And then has the following “filter query” NextReminderDate ge '@{formatDateTime(utcNow(), 'yyyy-MM-dd')}T00:00:00Z' and NextReminderDate lt '@{formatDateTime(addDays(utcNow(), 1), 'yyyy-MM-dd')}T00:00:00Z'
- A “Filter array” step which, in advanced mode, has the following inputs: From: "@outputs('Get_items')?['body/value']" Where: @and( greaterOrEquals( formatDateTime(convertTimeZone(item()?['NextReminderDate'], 'UTC', 'Eastern Standard Time'), 'yyyy-MM-ddTHH:mm'), formatDateTime(convertTimeZone(addMinutes(utcNow(), -1), 'UTC', 'Eastern Standard Time'), 'yyyy-MM-ddTHH:mm') ), lessOrEquals( formatDateTime(convertTimeZone(item()?['NextReminderDate'], 'UTC', 'Eastern Standard Time'), 'yyyy-MM-ddTHH:mm'), formatDateTime(convertTimeZone(addMinutes(utcNow(), 1), 'UTC', 'Eastern Standard Time'), 'yyyy-MM-ddTHH:mm') ) )
- A “Compose” step for debugging whose input is: @{outputs('Filter_array')
- An "Apply to each" called “Apply to Each 5” who is referencing this output: @{body('Filter_array')?['body'] Nested within this is another “Apply to each” called “Apply to each” which loops on @{items('Apply_to_each_5')
Nested within this is another “Apply to each” called “First day email” and this is looping on @{items('Apply_to_each')}
Within “First day email” there is a “Switch” and in the “On” field: @{items('First_Day_Email')?['ReminderStatus/Value']} The “Case” is: Equals “First Day” Then there is a “Condition”: items(‘First_Day_Email’)?[EmployeeCommunicationLanguage/Value’] contains “English” This then sends the appropriate email, either English and French using a "Send an Email V2" to send the English "First Day" email (if no it sends a French version) and then updates the sharepoint list items involved so that the "Next Reminder Date" is a set to a number of days as determined by this expression: @{addDays(items('First_day_email')?['StartDate'], X)} where X is the number of days after the start date that the next reminder should be sent. it also updates the Reminder Status Value to "Two Months" so it knows that when it comes time to send this contact a reminder email that it's the correct email. The flow continues and does basically the same kind of thing as in point 5 in this bullet list for Reminder Status value 2 Months, a manager reminder email, and then Three Months. 4 emails in total.
Here's the thing, when doing this, I ALWAYS get an error at the start of step 5 in this bullet list: The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each_5')' is of type 'Object'. The result must be a valid array.
I am trying to troubleshoot this and can't get far.
Checking Compose output shows this (some item data modded for security):
{
"body": [
{
"@odata.etag": "\"321\"",
"ItemInternalId": "26",
"ID": 26,
"UserName": "[email protected]",
"FirstName": "John",
"LastName": "Doe",
"EmailAddress": "[email protected]",
"EmployeeCommunicationLanguage": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 0,
"Value": "English"
},
"EmployeeCommunicationLanguage#Id": 0,
"ManagerEmail": "[email protected]",
"ManagerCommunicationLanguage": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 0,
"Value": "English"
},
"ManagerCommunicationLanguage#Id": 0,
"StartDate": "2024-11-21T14:30:00Z",
"NextReminderDate": "2024-11-21T14:30:00Z",
"ReminderStatus": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 0,
"Value": "First Day"
},
"ReminderStatus#Id": 0,
"Birthday": "2024-10-10",
"EmailOptIn": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 0,
"Value": "Yes"
},
"EmailOptIn#Id": 0,
"YearsOfService": 0,
"Modified": "2024-11-21T14:26:52Z",
"Created": "2024-04-22T02:23:07Z",
"Author": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
"Claims": "i:0#.f|membership|[email protected]",
"DisplayName": "Johnny Doe",
"Email": "[email protected]",
"Picture": "https://company365.sharepoint.com/sites/Marketing/_layouts/15/UserPhoto.aspx?Size=L&[email protected]",
"Department": "Marketing",
"JobTitle": "Marketing Manager"
},
"Author#Claims": "i:0#.f|membership|[email protected]",
"Editor": {
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
"Claims": "i:0#.f|membership|[email protected]",
"DisplayName": "Johnny Doe",
"Email": "[email protected]",
"Picture": "https://company365.sharepoint.com/sites/Marketing/_layouts/15/UserPhoto.aspx?Size=L&[email protected]",
"Department": "Marketing",
"JobTitle": "Marketing Manager"
},
"Editor#Claims": "i:0#.f|membership|[email protected]",
"{Identifier}": "Lists%252fTest%2bHR%2bMailing%2bDB%252f26_.000",
"{IsFolder}": false,
"{Thumbnail}": {
"Large": null,
"Medium": null,
"Small": null
},
"{Link}": "https://company365.sharepoint.com/sites/Marketing/_layouts/15/listform.aspx?PageType=4&ListId=f005fd8d%2D3901%2D474a%2Dbe7a%2D3cdbd4fbd149&ID=26&ContentTypeID=0x0100EB5F7FD3E55DCC4CA6D5F13E31528A90001D414B65A006B34A9D620F2505659474",
"{Name}": "",
"{FilenameWithExtension}": "",
"{Path}": "Lists/Test HR Mailing DB/",
"{FullPath}": "Lists/Test HR Mailing DB/26_.000",
"{HasAttachments}": false,
"{VersionNumber}": "321.0"
}
]
}
Share
Improve this question
edited Nov 22, 2024 at 14:55
WmW
asked Nov 21, 2024 at 19:31
WmWWmW
354 bronze badges
2
- Show us the JSON you're trying to filter on. – Skin Commented Nov 22, 2024 at 0:58
- JSON added above. – WmW Commented Nov 22, 2024 at 14:52
1 Answer
Reset to default -1There are 2-3 things I suspect that may be going wrong.
check the output of body('Filter_array')?['body']
and body('Filter_array')
as usually, filter array outputs the array directly instead of having a property (say 'body' in this case)
Next, items()?['Apply_to_Each']
is supposed to be an array but it's not because items()
is an object/singular element in an array being accessed in the loop.
So let's say you have an array A being looped over, so each loop instance will use the item()
which will in fact be an object UNLESS you have an array of arrays.
so see the and analyze the input to make it easier and
本文标签: Power Automate Filter Array output quotobjectquot issueStack Overflow
版权声明:本文标题:Power Automate Filter Array output "object" issue - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736307690a1933402.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论