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

Move a document to another library after a date is past

I have a SharePoint Document Library called Change Controls Submitted.

Users upload documents into it and I have set up flows to notify people and flows for approval. These all work so thats good...

One of the columns in the library is "Proposed Change Date" a compulsory date field for the date the change will be applied.

What I want to do is regularly check the library and move any documents where the "Proposed Change Date" is more than 24 hours in the past.

 

Im thinking it would be

  • Get Items,
  • then a Condition for when the value of "Proposed Change Date" is more than 24 hours past
  • Move File to an existing library called "Change Controls Completed"

Im thinking I need an expression to define the Condition using utcnow() and somehow saying 

"when utcnow() is more than 24 hours later than Proposed Change Date"

But I can't work out how to express that, can anyone help?

 

Adam.

 

 

14 REPLIES 14
Super User
Super User

Re: Move a document to another library after a date is past

Hi,

 

You could check this under the IF condition using the expression condition addDays and utcnow() 

 

cd1.png

 

addDays(ProposedChangeDate, 1)
Here map the ProposedChageDatefield
 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

Thanks

 
 


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Community Support Team
Community Support Team

Re: Move a document to another library after a date is past

Hi @AdamInLondon ,

 

Does the "Proposed Change Date" column's Date include Time?

 

If the "Proposed Change Date" column's Date don't include Time, please refer to screenshot below to create the flow:

1.png

And the expression in the flow as below:

formatdatetime(addHours(utcnow(),-24),'yyyy-MM-dd')

If the "Proposed Change Date" column's Date include Time, please refer to screenshot below to create the flow:

2.png

 

The two expressions in the flow should as below:

formatdatetime(items('Apply_to_each')?['ProposedChangeDate'],'yyyy-MM-ddTHH:mm:ssZ')
formatdatetime(addHours(utcnow(),-24),'yyyy-MM-ddTHH:mm:ssZ')

Please let me know if your problem could be solved.

 

Best regards,

Alice       

 

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

 

AdamInLondon
Level: Powered On

Re: Move a document to another library after a date is past

Thanks for your help Alice. Im almost there

The flow fails on the "Apply to each" step with error ActionFailed. An action failed. No dependent actions succeeded.

Here is my flow:

Recurrence every 5 minutes (thats for testing, it will be once a week in production)

The Date does not include the time so I have used your first expression example

formatdatetime(addHours(utcnow(),-24),'yyyy-MM-dd')

 

Adam.

 

Completed 1.JPG

Completed 2.JPGCompleted 3.JPG

Completed 4.JPG

 

 

jwhite
Level 8

Re: Move a document to another library after a date is past

Hi @AdamInLondon,

That step of the apply to each succeded (i.e. it was false so it did nothing), could you please hit "Next failed" to find the step which has an issue and show the error?

Community Support Team
Community Support Team

Re: Move a document to another library after a date is past

Hi @AdamInLondon ,

 

Please check from all the 3 runs in the Apply to each and please share the screenshot of the error action in the 3 loops.

1.png

And I see you choose the Id Dynamic content in the File to Move field, please choose the Identifier Dynamic content in the File to Move field to see if your flow could work.

2.png 

 

Best regards,

Alice       

 

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

AdamInLondon
Level: Powered On

Re: Move a document to another library after a date is past

Thanks, I have changed the 'File to move' to Identifier but the flow still fails.

Here is the detail on the three Fails, they are all the same.

Completed 5.JPG

jwhite
Level 8

Re: Move a document to another library after a date is past

Hi @AdamInLondon, could you please expand the "Move file" action that failed in that apply to each section to show the error that caused the flow to fail?

Community Support Team
Community Support Team

Re: Move a document to another library after a date is past

Hi @AdamInLondon ,

 

As @jwhite asked, please share the error message in the "Move file" action when it is failed.

Also please make sure you have choose the folder from the Picker in the "Destination Folder" field.

 

Best regards,

Alice       

 

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

 

AdamInLondon
Level: Powered On

Re: Move a document to another library after a date is past

Hello here it is, followed by the text of the error. I have replaced our domain name with DOMAIN NAME:

Completed 6.JPG

 

"status": 400,
  "message": "Failed to verify the existence of source object at 'https://DOMAIN NAME.sharepoint.com/sites/ServiceInformationandManagement/54' due to error 'The system cannot find the file specified. (Exception from HRESULT: 0x80070002)'.\r\nclientRequestId: a5e112cf-3524-4908-872e-de9cf1448b4b\r\nserviceRequestId: a5e112cf-3524-4908-872e-de9cf1448b4b"
AdamInLondon
Level: Powered On

Re: Move a document to another library after a date is past

Also this flow is not pointing to a Folder, it is pointing to another Document Library, does that matter?

Community Support Team
Community Support Team

Re: Move a document to another library after a date is past

Hi @AdamInLondon ,

 

Please don't replace the domain name.

 

Best regards,

Alice       

 

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

AdamInLondon
Level: Powered On

Re: Move a document to another library after a date is past

OK here is the message:

"status": 400,
  "message": "Failed to verify the existence of source object at 'https://britishmuseum.sharepoint.com/sites/ServiceInformationandManagement/54' due to error 'The system cannot find the file specified. (Exception from HRESULT: 0x80070002)'.\r\nclientRequestId: a5e112cf-3524-4908-872e-de9cf1448b4b\r\nserviceRequestId: a5e112cf-3524-4908-872e-de9cf1448b4b"
AdamInLondon
Level: Powered On

Re: Move a document to another library after a date is past

Hello Alice and other community members.

 

I am still struggling with this.

The column "Proposed Change Date" is a date and time field so I have used both your formulae but I still get errors.

 

Here is a breakdown of the whole flow.

What I want to happen:

1. Users move a document into a Document Library called "Change Controls Submitted"

2. The Document Library called "Change Controls Submitted" contains a compulsory date and time column called "Proposed Change Date"

3. The Flow is to check the Document Library called "Change Controls Submitted" on a schedule and move any document where the "Proposed Change Date" is more than 24 hours in the past to another Document Library called "Change Controls Completed"

 

Here is the format of the Proposed Change Date column:

Details 1.JPGDetails 2.JPG

Here is my Flow:

(Note I have set the recurrence to every 5 minutes but this is just for testing)

Details 3.JPG

First Apply to each condition:

Details 4.JPG

Here are the expressions:

The one on the left:

formatdatetime(items('Apply_to_each')?['Proposed Change Date'],'yyyy-MM-ddTHH:mm:ssZ')
The one on the right:
formatdatetime(addHours(utcnow(),-24),'yyyy-MM-ddTHH:mm:ssZ')
The "If yes" part:
Details 5.JPG

And finally here is the Error that I get when the Flow runs:

Details 6.JPG

And this is the text of the error:

Unable to process template language expressions for action 'Condition' at line '1' and column '2679': 'The template language function 'formatdatetime' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.

 

Another detail which may not be important...

I am trying to move files from one Document Library to another but some advice refers to the name of the "Folder"

I am not using Folders, I am using Document LIbraries... does that matter???

 

As always very grateful for your help.

AdamInLondon
Level: Powered On

Re: Move a document to another library after a date is past

It has been a while since I first posted this so I am marking it as New. 

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Coming Soon: T-shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

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!

sixthImage

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors
Users online (5,320)