This error just started 3 days ago after running successfully for 3 months. This is the error MS gives:
The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each_2')?['{Identifier}']' is of type 'String'. The result must be a valid array.
The flow checks the age of files in a SharePoint and deletes those over 180 days old - the error seems to be pointing at the Identifier value in the nested loop:
I'm not sure why the error has started since the backend SharePoint files haven't changed nor have I touched this Flow since March.
Testing that change succeeded - I remember setting this up and not wanting the nested loop but Automate kept creating it when I selected Delete File as an action. It was odd but I'd never made a flow before so I thought it might be required.
Thank you!
After looking at your flow again, I don't know how it could be working in the first place.
The first apply to each "Apply to each 2" is based on a SharePoint get files step. So for each file it will do actions within "Apply to each 2".
The second apply to each "Apply to each" is trying to say, "For each individual file in Apply to each 2, I would like to get each Identifier for that individual file. The do actions to each one of those identifiers."
That doesn't make sense. Each file only has 1 identifier, it doesn't have a list of identifiers.
I made an example and mine failed because it can't apply to each on an identifer.
Example Apply to Each
Example Apply to Each Failed
So I don't know how this flow was working at all for months. It doesn't work once. I can only guess it never had any files that were 180 days old, so it never got any further than the first "Apply to each 2" because it was always empty. So the second "Apply to each" never got a chance to run and create an error.
You should get rid of that nested apply to each and you only need one.
Delete a File
This example should work correctly. Let me know if this works for you.
All the files are labelled "YYYY-MM-DDT##_##_##+##_##-REPORTNAME" where the # are integers and I have no idea why there is a letter T after the date. The file names are all the same except for the data and however the #'s are assigned from our ERP that spits these out; e.g.: "2023-02-06T23_45_39+00_00-Primary Ledger Trial Balance YTD".
The file name format hasn't changed since I set this flow up either, so I hope that it isn't the problem.
Are there any files or folders with special characters that you know of? Like @ % & * ' " { ]
I'm only guessing to troubleshoot. Sometimes special characters throw off the power automate code as it is transmitted. I don't know what it could be but maybe something to check for.
WarrenBelz
146,635
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional