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

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Loop through SharePoint selected item file inputs

(0) ShareShare
ReportReport
Posted on by 76

Hi,

 

I created a flow to run on a selected SharePoint list item. I want the user to be able to add a few file inputs to that flow.

 

How do I loop through those files? The user optionally attaches any number from 0 to 5 files.

 

In the triggerbody, if there are 5 files attached, then the JSON is:

{

  "file": {filecontent},

  "file_1": {file_1content},

  "file_2": {file_2content},

  "file_3": {file_3content},

  "file_4": {file_4content},

  "entity": {sharepoint_item_info}

}

 

The stuff in italics is description of what the actual values are.

 

I'm trying to get those filenames but I don't know how to formulate the expression for the Apply to each action.

 

Please help!

I have the same question (0)
  • efialttes Profile Picture
    14,756 on at
    Re: Loop through SharePoint selected item file inputs

    Hi!

    It is an object, meaning you cannot assign as input to an Apply to Each (expects Arrays).

    Give me one more minute

     

  • Verified answer
    efialttes Profile Picture
    14,756 on at
    Re: Loop through SharePoint selected item file inputs

    Hi again!

    I created a test flow, can add max two files,added file and file 1 outputs to compose action blocks:

    Flow_manualAttach_1.png

     

    then executed it by just adding one

     

    Flow_manualAttach.png

    This means you probably need to add a Condition action block per File, evaluate if null, if false then do whatever stuff you need to do with it. If true, means, not uploaded.

    Hope this helps

  • efialttes Profile Picture
    14,756 on at
    Re: Loop through SharePoint selected item file inputs

    Hi again!

    Verified, Conditions are needed, one per file. Remember in my example I allow max 2 files, just upload the first one

    Flow_manualAttach_2.pngFlow_manualAttach_3.png

    Hope this helps

     

  • i_power Profile Picture
    76 on at
    Re: Loop through SharePoint selected item file inputs

    Okay, not looping and evaluating to null is fine...

     

    But could you please tell me what expressions you used in the Compose actions? I'm new to PA and I can't work out what the expressions should be to work out the way yours do. Thanks!

  • i_power Profile Picture
    76 on at
    Re: Loop through SharePoint selected item file inputs

    Great, thanks for showing that in detail.

     

    Is  that first Compose with triggerbody() needed? The subsequent actions' expressions refer back to triggerbody anyway.

  • efialttes Profile Picture
    14,756 on at
    Re: Loop through SharePoint selected item file inputs

    Hi!

    In my test Flow, Compose actions are just for troubleshooting purposes...

    'Compose triggerBody()', I just added the expression

     

     

    triggerBody()

     

     

    in order to inspect trigger Body() content easier. How to add expressions? Explained here

    https://flow.microsoft.com/es-es/blog/use-expressions-in-actions/

     

    'Compose File content', I am just assigning 'File content' from dynamic content menu

    'Compose File content 1', I am just assigning 'File content 1' from dynamic content menu

     

    Flow_manualAttach_4.png

     

    As I said, the three Compose action blocks were for faster troubleshooting , the first one to see triggerBody() content faster, the other two to see if Flow execution fails or not, much faster than adding a "One Drive Create file" or "Sharepoint Create file".

     


    I'm new to PA and I can't work out what the expressions should be to work out the way yours do. Thanks!

    New to PA? No problema. You will realize how fast you can learn...

     

    Thanx for your contribution to keep this community great!

  • efialttes Profile Picture
    14,756 on at
    Re: Loop through SharePoint selected item file inputs

    Thanx for your kindness!

     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 655 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 371 Moderator

#3
chiaraalina Profile Picture

chiaraalina 276

Last 30 days Overall leaderboard