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

Delete files from folder after 180 days

Hello,

 

I'm trying to create a flow that deletes files after 180 days from specific folders.  I've created a flow but everytime it runs it keeps failing.  I have a picture below of my flow that I've created.

 

 

Below is the failure message I'm recieving.  Any suggestions as to why it would be failing?  Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @MattyJ2009,

 

I think there is something wrong with the formula filled in your Condition box, the output of "List files in folder" action returned doesn't contain Created property.

 

I have made a test on my side and please take a try with the following workaround:12.JPG

Within Condition box, click "Edit in advanced mode", type the following formula (for testing on my side😞

@greater(utcNow('yyyyMMdd'), formatDateTime(addDays(item()?['LastModified'], 5), 'yyyyMMdd'))

On your side, you should type the following formula within your Condition box:

@greater(utcNow('yyyyMMdd'), formatDateTime(addDays(item()?['LastModified'], 180), 'yyyyMMdd'))

Within "Delete file" action, File field set to Id dynamic content of List files in folder" action.

 

The flow works successfully as below:13.JPG

 

 

More details about the output of "List files in folder" action of FIle System connector, please check the following article:

List files in folder

 

 

Best regards,

Kris

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

2 REPLIES 2

The problem is either in the condition or in the delete file.

 

I would start by vreaking things up in variables. So rather than having the complicated expression in the condition set a variable to this condition.  Does this work? Or does this fail? If it works, what is the value you get returned?

 

You could even try to get the return value of the adddays put into a variable. This way splitting up your expression into smaller expressions will make it easier to debug.

 

 

v-xida-msft
Community Support
Community Support

Hi @MattyJ2009,

 

I think there is something wrong with the formula filled in your Condition box, the output of "List files in folder" action returned doesn't contain Created property.

 

I have made a test on my side and please take a try with the following workaround:12.JPG

Within Condition box, click "Edit in advanced mode", type the following formula (for testing on my side😞

@greater(utcNow('yyyyMMdd'), formatDateTime(addDays(item()?['LastModified'], 5), 'yyyyMMdd'))

On your side, you should type the following formula within your Condition box:

@greater(utcNow('yyyyMMdd'), formatDateTime(addDays(item()?['LastModified'], 180), 'yyyyMMdd'))

Within "Delete file" action, File field set to Id dynamic content of List files in folder" action.

 

The flow works successfully as below:13.JPG

 

 

More details about the output of "List files in folder" action of FIle System connector, please check the following article:

List files in folder

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
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
MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (17,659)