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

Flow Expressions: How can I determine if a SharePoint file created date is 7 days old?

I am trying to create a flow that will update a particular file property for items in a SharePoint list on a regular schedule. 

 

In my SharePoint list, I have a custom "Archive" column with Yes/No choice options. I want my flow to run once a week and automatically check "No" in the Archive column if the file created date is seven days old.

 

What is the correct expression(s) to use for determing if the created date is 7 days old? I assumed I should use the subtractFromTime expression, but I am not having success.

 

subtracttime.PNG

 

 

4 REPLIES 4
Community Support Team
Community Support Team

Re: Flow Expressions: How can I determine if a SharePoint file created date is 7 days old?

Hi @kelliprieto,

 

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

  • Add Recurrence trigger, Interval set to 1, Frequency set to Week.
  • Add “Get items” action, specify Site Address and List Name.
  • Add “Apply to each”, input parameter set to output of “Get items” action.
  • Within “Apply to each”, add a Condition box, click “Edit in advanced mode”, type the following formula:
@equals(formatDateTime(addDays(items('Apply_to_each')?['Created'], 7), 'MM/dd/yyyy'), formatDateTime(utcNow(), 'MM/dd/yyyy'))
  • Within “If/yes” branch of Condition, add “Update file properties” action.

Image reference:9.JPG

The flow works successfully as below:10.JPG

 

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.
kelliprieto
Level: Powered On

Re: Flow Expressions: How can I determine if a SharePoint file created date is 7 days old?

Kris,

 

 

Thank you for responding! This is great.

 

 

 

I cannot use "Get Items", because the files I want to automatically archive are not list items. The files are in a Document Library, so I should use "Get file (properties only)", correct?

 

I applied the recommended changes to the flow, but I have not been able to successfully run it yet. The flow says it ran successfully, but it is not updating the files.

 

Kelli

Community Support Team
Community Support Team

Re: Flow Expressions: How can I determine if a SharePoint file created date is 7 days old?

Hi @kelliprieto,

 

The SharePoint document library is a list actually, on my side, I use SharePoint Document Library name as a custom value of List Name field in "Get items" action.13.JPG

 

Note: You can upload a pbix file to Onedrive or any web storage and share the link. Do mask sensitive data before uploading. 

 

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.
kelliprieto
Level: Powered On

Re: Flow Expressions: How can I determine if a SharePoint file created date is 7 days old?

Kris,

 

Thank you for this additional information. I updated the flow accordingly. 

 

I am still not getting the expected results. For example, I have a document with a created date of 10/16/2017. I am expecting the "Archive" property to be updated to "Yes" when the flow runs. 

 

Below is a screenshot of the archive step of my flow.

 

Kelli

 

archive.PNG

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

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 Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 517 members 4,691 guests
Please welcome our newest community members: