I have a flow where there is a switch command for three different statuses, 1) Approved, 2) Rejected and 3) Pending. If a request (list item in Pending List) is approved, then it follows down the Approved line under the switch, runs a Get Attachments, Creates a new item in the Approved Request list, then runs through an apply to each phase to grab all attachments and adds those attachments to the newly created Approved List item. This works fine, however, I reproduced the exact same steps under the Rejected lane for the switch command and what is happening is that it creates the Rejected List item just fine, EVEN with the attachments, but then seems to fail as a Bad Request after successful ones in the Add Attachments section. The Error stage and Flow is shown below, any help would be greatly appreciated.
Get Updated List Item
Create New Rejected List Item
Get Updated Item Attachments
Get Attachment Contents and Add Attachments to New Rejected List Item
Minimized Rejected Case Flow Steps
@Lday75 your flow looks correct, are you sure the dynamic content that you are using in Add Attachments -rejected is from the Get Attachment - rejected action? Can you please double check the dynamic content used in this action? Also does it show any error other than Bad Request?
yes, I have verified and the three dynamic content items are all from the rejected side tiles. No clue as to why this swimlane fails and Approved works just fine. The kicker is that I am getting the proper rejected item list and the attachments do show, yet the action runs an additional iteration and fails at that point which will prevent the remaining items I need to run in the rejected swimlane. very odd.
@Lday75 does it show more error details other than Bad Request? Can you test the flow with different data?
Shown below are the errors I see in the flow, what is interesting is that in this case, there was only 1 file attached, yet the Apply to each - get value for rejected ran five times, on the first iteration, the file was picked up as it should have been, yet the next four iterations show the error, and when I download the output from the errors it shows as
"status":400,"message":"The specified name is already in use.\n\nThe document or folder name was not changed. To change the name to a different value, close this dialog and edit the properties of the document or
I'm not sure how to get this part worked out to where it only picks up the file once, why the five iterations for the apply to each here?
@Lday75 the value that you are using in "Apply to each - get value for rejected" what values are there in that "value" dynamic content, can you please check that in your flow run? That looks like the issue with your flow.
The error that you are getting on add attached is because the file with same name already exists at that location that is why you are getting "The specified name is already in use" error.
@annajhaveri the value going in is correct, it is setup exactly as I have it in the approved column in the switch statement. That is what is throwing me off here, why would these act differently when they are setup exactly the same. I tried moving the Create Rejected item inside of the Apply to each - get value for rejected and it works without error....however it now creates a list item for as many files that are attached, plus 1. So if 2 files are attached, I get three rejected list items.
@Lday75 i think Create Rejected Item should be out of apply to each. Why do you have two loops one is Apply to each - get value for reject and other is apply to each - get attachments for rejected, are these both looping through different collection. I think shouldnt there be just one loop to loop through attachments?
@annajhaveri I moved the Create Rejected Item out of that loop, that was just an example of how I saw it on another post, doing it this way above worked without error, but created the multiple Rejected List Items (as expected). The way my flow is now is shown below. I built it this way based on an article I found explaining how to copy a list item with attachments. Again, what I do not understand is why this process under the Approved Case swimlane working without error, when it is built the exact same way.
These are the two "swimlanes" under a Switch tile (out of the image). The left column is the Approved Case, everything here works as expected with no errors. The right side (which will be middle once I add a new case) is the Rejected side, this does copy the list item, and the attachments, but the Apply to each - get value for rejected is running a second time for some reason. Successful vs Error results are shown below as well.
Approved vs Rejected Case lanes
This shows a successful run on the approved side, Apply to each - get value for Approved only runs once
Rejected side, showing the apply to each - get value for rejected running twice.