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 / Create individual link...
Power Automate
Suggested Answer

Create individual links in email for number of files using 'Upload File' MS Forms & Power Automate

(0) ShareShare
ReportReport
Posted on by 8
So, I've created a form to allow users answer a few questions and then attach between 0 and 3 files.
During the questions, there is one that asks if they want to add attachments.
This creates a branch, where selecting "Yes" prompts them with one more question that allows them to upload files.
 
In Power Automate, I can use the switch to determine if they are including attachments or not.
If not, that's easy.  If they select to add attachments, the attachments get uploaded to 'Onedrive for Business' and I want to create a link to the attachments.
 
I found that using "Compose" (Data Operation), I can then run the following:
split(outputs('Get_response_details')?['body/rb9f8e1615ba8469fba578aa206283c2e'], '"')[7]
 
I can then add the output to the email body and using the code editing, make it a hyperlink.
<a href="@{outputs('Attachment')}" class="editor-link">Click to view attachment</a>
 
 
This works fine.  I can also do this to process three files by creating additional "Compose" actions and using the following:
split(outputs('Get_response_details')?['body/rb9f8e1615ba8469fba578aa206283c2e'], '"')[35]
split(outputs('Get_response_details')?['body/rb9f8e1615ba8469fba578aa206283c2e'], '"')[63]
 
And then in the body, I can add additional links, etc. 
 
The problem!
 
If I configure this to be able to process up to 3 files, it expects 3, and if a user submits one file it breaks.
 
The question!
How can I make this more dynamic?
 
Thoughts include:
Can I parse the attachments info and determine how many times "name" or "link" appears and then loop it that many times to process all files regardless of how many?
Is there another way to break down how many attachments were included?  If so, I could create another "switch" and then have a case for each number of attachments.  This feels clunky and like bad coding though.  I think a loop would be more efficient, but I am not familiar enough with JSON, and Power Automate to know where/how to do this.
 
Also, if there is a way to do "if/then" statements in the email to display information based on variables being set or not would be very helpful too.
For instance, if the user only submits two files, there's no reason to have a link for 3 files.
 
So a test like:
if attachment1 has value other than null, display link, else do not display link.
 
Any suggestions?
 
Thanks!
 
Categories:
I have the same question (0)
  • Suggested answer
    Mark Nanneman Profile Picture
    993 Moderator on at
    To do this dynamically in the proper way, I'd recommend this method:
     

    Step One: Convert Your File Attachments Property into a JSON Array

    Use a "Compose" to store an array of your uploaded files.  The uploaded files come over in a JSON array in string format.  So you have to convert it back to JSON to work with it.
     
    Just use the expression editor to place a refence to your files property from your form in a json() function.
    e.g.
     
     

    Step Two: Create a HTML template and store it in a compose

     

    Step Three: Use a select to create an array of links based on the HTML template



    Step Four: Join Your Array of Links into a string

     

    Then drop this into your email html where you want it to display.
     
    Test
     
     
     

    Alternatively, you can use an "Apply to Each" loop

    If you're not comfortable using the template and Select method above, you can use the traditional "Apply to Each" loop that takes your File Attachments array and just construct and append each link to a string variable that holds your links.

    Something like:


    If this helped you, please click "Does this answer your question" and give it a like to help others in the community (+ close the ticket)!

    Power Platform Developer | LinkedIn: Mark Nanneman | Blog: Power Stuff  | YouTube: Mark's Power Stuff  |
     
     
  • RobElliott Profile Picture
    10,501 Super User 2026 Season 1 on at
    Further to Mark's answer, we have a global awards system at my company that uses a form to for the nomination and the submitter can attach up to 6 files but doesn't have to, so there could be anything from 0 to 6 files. They get saved via an apply to each into an array variable. We then save the nomination details to a SharePoint list with the uploaded files as attachments. You could do something similar then put a link to the item in the list into your email. Parts of my flow are shown below:

     
     
     
     
     
     
     
    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User.
    Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)
     
     
  • pdxwarrior Profile Picture
    8 on at
    'Hey @Mark Nanneman - thanks for the detailed information.
     
    I'm working through this, but have a question on step 3.  I don't see where I can select "body" like you have demonstrated.


    When I look for this, I get the following options:
     
    But selecting either of these, gives me the same icon as yours, but shows "output" not "body."
    Under 'dynamic content' I see "Body" but this gives me a different icon and references 'triggerBody()'
    which I'm not sure is correct:



    Also, the JSON text is saying to enter a valid JSON:

    Any thoughts on what I'm missing here?
     
    Thanks!
  • pdxwarrior Profile Picture
    8 on at
    Correction, I did notice an extra comma, which I have removed.  I still see the Invalid Parameters on the right and the 'Enter a valid JSON' message.
    Also, please see the comment prior to this for additional details.
     
    Thanks!

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 801

#2
Valantis Profile Picture

Valantis 602

#3
Haque Profile Picture

Haque 581

Last 30 days Overall leaderboard