cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gohanman
New Member

How to reference dynamic content inside a loop?

(I realize this forum has many similar threads; I've read them; I've read the documentation they link to; I'm still unsure how to do this).

 

I'm trying to write a Flow that scans through a Sharepoint folder, identifies PDFs, and move them into folders with corresponding names.

 

I've got:

1. Sharepoint List folder action

2. Apply to each on the Body from the previous action

3. Condition checking if the Name ends in ".pdf"

 

And that all seems to work correctly. I then want to have a sharepoint move action that uses an expression like replace(FILE_NAME_ATTRIBUTE, '.pdf', '') and I cannot figure out what the syntax needs to go in place of FILE_NAME_ATTRIBUTE. I tried triggerBody()?['Name'] and triggerBody()?['name'] which if I'm understanding any of this right doesn't work because triggerBody() is getting the entire result from the Sharepoint list folder rather than the subpart the current loop iteration is on, but I don't know where to go from there. In the GUI, as soon as I start an expression, the Name, DisplayName, Path, etc options vanish from the Dynamic Content list and the only option that remains is body.

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @gohanman,

 

Within a loop you can refer to an item() or item()['Name'].

 

So, in your setup could you try something like below:

 

replace(item()['Name'], '.pdf', '')

 

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


View solution in original post

2 REPLIES 2
Expiscornovus
Super User
Super User

Hi @gohanman,

 

Within a loop you can refer to an item() or item()['Name'].

 

So, in your setup could you try something like below:

 

replace(item()['Name'], '.pdf', '')

 

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Perfect, thanks!

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,110)