web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Adding Attachments, Ch...
Power Automate
Answered

Adding Attachments, Checking for Duplicates

(0) ShareShare
ReportReport
Posted on by 5

I have a form that requires 5 different photos to be attached. I have created a flow:

 

When a new response is submitted

Get response details

Parse JSON photo1

" photo2

" photo3

" photo4

" photo5

 

Get file content photo1

" photo2

" photo3

" photo4

" photo5

 

Condition: Check for duplicate images (this checks if Body name 1= Body name 2, etc)

 

Yes: Send email to respondent to resubmit

 

No: Create Item in Sharepoint

 

Add Attachment photo1

" photo2

" photo3

" photo4

" photo5

 

The flow is successful, however the photo attachments are empty.

 

I actually have two questions:

 

1. Is there a better way to do this? I've thought of allowing users to just upload 5 files, which tracks with the "for each" concept, but then I can't force 5 files to be uploaded.

 

2. What is the purpose of the "for each" in this case, given that each form question will only allow one file to be uploaded. The flow won't save without each "Get file content" & "Add Attachment" individually encased in a "For each", let alone run. This makes the flow look clunky,  and makes it impossible for me to use the proper outputs of "get file content" as a dynamic input, which I think is why the attachments are empty.

 

TIA!

Categories:
I have the same question (0)
  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @Delilah ,

     

    For the first question, if you need 5 files, no more, no less, to upload to the survey, you must use 5 questions and all of them are required.

     

    For the second question, the for each control emerges automatically because the outputs of Parse JSON are of type array. Although these arrays include only one object, you select an element of an array from dynamic contents, the control comes up.

     

    To your requirement, you can use a Compose to create an array where contains all the files from each Parse JSON, and use the array only once in an Apply to each control, loop it so the flow would be concise.

     

    I have two questions ask to upload a file in my form, so the flow is as follows:

    vjefferni_0-1713339569385.png

    vjefferni_1-1713339677399.png

     

    Expression in Compose of mine:

    [@{body('Parse_JSON')[0]},@{body('Parse_JSON_2')[0]}]

    so, yours would be as follows if you didn't change action names:

    [@{body('Parse_JSON')[0]},@{body('Parse_JSON_2')[0]},@{body('Parse_JSON_3')[0]},@{body('Parse_JSON_4')[0]},@{body('Parse_JSON_5')[0]}]

     

    in Condition control, it means checking if there are 5 unique objects in this array:

    length(union(outputs('Compose'),outputs('Compose')))

    in Get file content:

    items('Apply_to_each')['id']

    Add attachment:

    items('Apply_to_each')['name']

     

    Best regards,

  • Delilah Profile Picture
    5 on at

    Thank you for the swift and detailed response!

     

    I followed your instructions, and had issues with the condition, so I scrapped it. Hopefully I can trust my users to add 5 different photos...

     

    But the rest of the tips you gave really cleaned up my flow, so thank you!!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 589

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 284 Super User 2026 Season 1

Last 30 days Overall leaderboard