cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Itprofessional
Level: Powered On

Trying to delete all files from multiple document libraries

Deleting files from multiple document libraries
 

Basically what I want to do is to delete all the files from 20 libraries.  It's basically a cleanup flow.  I don't want to delete the libraries themselves but I want to delete the files / folders inside each library.

I can do this by manually doing a get items per library and then using the apply to each and then delete item action card and it works but what I want to do is to have a simpler flow that would read a list that has each document library name in it.  Do a get items based on that list.  Then return those library names to use in the next get items that would get the items in each library and then from there use the delete item action card to delete all the files.

It seems simple enough in my head but when I attempt to do the lookup of the document library names in the list that works fine and I return the output of all 20 libraries.  Then when I take those libraries and do a get items for each library I can do that and it works, BUT when I do the delete action card it doesn't allow me to select any of the output from the 2nd get items action card.  It only show's the first.  I'm new to flow so I'm sure I'm just doing something wrong but for the life of me I can't see what it is and why flow isn't allowing me to use any of the output listed from the 2nd get items to delete them.

Annotation 2019-03-08 183350.png

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
v-zhos-msft
Level 10

Re: Trying to delete all files from multiple document libraries

Hi @Itprofessional ,

I have made a flow as yours, I also can't use the output of 'Get items 2'.

However you can use the expression in the Id field to get the ID from 'Get items 2'.

I have made a test on my side, please take a try with the following workaround:

The expression in Id field is : item()?['ID']

Capture5.PNG

Best Regards,

Community Support Team _ Zhongys

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

4 REPLIES 4
bart_vermeersch
Level: Powered On

Re: Trying to delete all files from multiple document libraries

I believe you forgot to loop through the files within the selected library.
You will need a nested loop before you can delete an item within the library.
Itprofessional
Level: Powered On

Re: Trying to delete all files from multiple document libraries

I am doing a loop with an apply to each to get the files.  From the get items 2 action card I can see the output of each library and it returns the files in which I need to grab the ID from but as show in the screenshot I do not have access to the get items 2 action card to use the file identifier ID from which is what I'm having issue with.

In the flow I can see the output of the data I need to remove but in the dynamic content I am unable to select the ID from the get items 2 action card output for some reason.

 

I'm sure it's syntax or something as I'm new to flow but what I need to do is list the library contents so I can then remove them which in the output from testing is there but I just can't seem to find a way to actually select it even though it's being returned as an output.


Highlighted
v-zhos-msft
Level 10

Re: Trying to delete all files from multiple document libraries

Hi @Itprofessional ,

I have made a flow as yours, I also can't use the output of 'Get items 2'.

However you can use the expression in the Id field to get the ID from 'Get items 2'.

I have made a test on my side, please take a try with the following workaround:

The expression in Id field is : item()?['ID']

Capture5.PNG

Best Regards,

Community Support Team _ Zhongys

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

Itprofessional
Level: Powered On

Re: Trying to delete all files from multiple document libraries

@v-zhos-msft That worked!

 

It's so odd you can't use the ID from dynamic content as it doesn't show up but forcing the expression worked fine and it actually resolved when being saved to the "blue" ID from the 2nd apply to each.  

 

Perhaps it's a bug?  Either way it worked wonderfully and thank you very much for the help!


Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 155 members 5,184 guests
Please welcome our newest community members: