cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Trying to create flow to delete all docs in lib 1 day after creation. Struggling

I have an O365 Tea, site with a doc lib. I need a flow that will delete any docs added to that library after 2 days. I am having trouble getting the samples on the web to work. Seems like a simple if create date < 2 days, delete. 
Can anyone help me?  Seems easy but I’m stuck. 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Solution Sage
Solution Sage

Re: Trying to create flow to delete all docs in lib 1 day after creation. Struggling

Hello @Jimeh 

No, the expression you wrote is not correct, since you closing the body -> "(body)" and you shouldn't. Have a look again at the expression:

Created lt '@{startOfDay(body('Substract_from_time'),'yyyy-MM-ddTHH:mm:ssZ')}'

So, you only need to remove the ")" character after the word "body".

Hope it helps!

Ferran 

View solution in original post

Highlighted
Community Support
Community Support

Re: Trying to create flow to delete all docs in lib 1 day after creation. Struggling

 

Hi @Jimeh ,

 

Also, you could try this configuration:

9.PNG

Hope this helps.

 

Best Regards,

Community Support Team _ Barry
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

5 REPLIES 5
Highlighted
Solution Sage
Solution Sage

Re: Trying to create flow to delete all docs in lib 1 day after creation. Struggling

Hello @Jimeh 

You could do something like this:

delete.png

 

1) Recurrence: For each day

2) Substract from the current date two days.

3) Get the files where the created column is less than the time calculated at step 2, using the following expression:

Created lt '@{startOfDay(body('Substract_from_time'),'yyyy-MM-ddTHH:mm:ssZ')}'

 4) For each found file, delete it.

 

Hope it helps!

Ferran

Highlighted
Community Support
Community Support

Re: Trying to create flow to delete all docs in lib 1 day after creation. Struggling

 

Hi @Jimeh ,

 

Also, you could try to use the following expression:

1.PNG

Hope this helps.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Regular Visitor

Re: Trying to create flow to delete all docs in lib 1 day after creation. Struggling

Thanks Ferran. I am getting an error with the filter. Do I have this correct?

 

startOfDay(body)('Subtract_from_time’),’yyyy-MM-ddTHH:mm:ssZ')

Highlighted
Solution Sage
Solution Sage

Re: Trying to create flow to delete all docs in lib 1 day after creation. Struggling

Hello @Jimeh 

No, the expression you wrote is not correct, since you closing the body -> "(body)" and you shouldn't. Have a look again at the expression:

Created lt '@{startOfDay(body('Substract_from_time'),'yyyy-MM-ddTHH:mm:ssZ')}'

So, you only need to remove the ")" character after the word "body".

Hope it helps!

Ferran 

View solution in original post

Highlighted
Community Support
Community Support

Re: Trying to create flow to delete all docs in lib 1 day after creation. Struggling

 

Hi @Jimeh ,

 

Also, you could try this configuration:

9.PNG

Hope this helps.

 

Best Regards,

Community Support Team _ Barry
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

Helpful resources

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Top Solution Authors
Users online (5,784)