Reputation: 35
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:
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"
}
]
}
Upvotes: 0
Views: 493
Reputation: 1
After looking for a long time, I finally noticed something. Depending on the type of column of choice in SharePoint, the result transmitted is either an array or a json. Moral (and to make it short) if you want an array use the "Check boxes (allow multiple selections)" otherwise you will have objects.
See you later!
Upvotes: 0
Reputation: 446
There 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
Upvotes: -1