cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jimeh
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

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 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

View solution in original post

 

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
fchopo
Super User
Super User

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

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
v-bacao-msft
Community Support
Community Support

 

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.

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')

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 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

 

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.

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.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (2,465)