Hi,
I'm trying to create a flow on OneDrive for Business where if a document is modified after it's uploaded to a folder it will automatically move to a different folder.
For example if a user saves a document to a certain folder (let's call it 'Pending') because it's not necessarily finished as it needs input from someone else, it will automatically move (to a 'Complete' folder) it once this person updates or modifies it because the date & time are different to the date & time created.
I've struggled to make one to move the document so I tried to make a flow that will clone the original once it's been saved and put it into the 'Complete' folder and then delete the original from the 'Pending' folder. The trigger is also 'When a file is modified' but it currently runs the Flow the moment a document is saved into the 'Pending' folder.
Essentially what I need is to set it so that it only triggers the Flow if the Date Modified is greater than the Date Created. It needs to also take the time into accound & not just the date as very often these get done on the same day that they are uploaded.
Solved! Go to Solution.
The behavior you are seeing using the OneDrive Sync client is what I would expect. The file is created on the Desktop and then synced to OneDrive by the OneDrive client. That sync counts as a modification. I don't really see an easy way to get around that since it actually does count as a modification.
Add the following code to the Trigger Conditions in Settings for the Trigger. The Flow will then only trigger when Modified does not equal Created.
@not(equals(triggerBody()?['Created'],triggerBody()?['Modified']))
Hi Thank you for your assistance.
I added the code to the Trigger Conditions as suggested but unfortunately it stopped the flow from running at all. I made changes to the document that I added last week in case it wasn't taking the time as part of the date created but the flow didn't run and therefore the file stayed in the same folder.
Which trigger are you using? I tested it with the When a file is created or modified (properties only) trigger and it works fine. If you are using a different trigger it may not be returning the created and modified properties. In that case the filter will never work.
I'm using the 'When a file is Modified' trigger. I can only find the trigger you mentioned in your last update within the SharePoint triggers and not OneDrive for Business which is what is required. The only options I have in OneDrive for Business that I can use in a Trigger are:
Sorry, i didn't pick up on the fact that this was OneDrive for Business (even though you had it in Bold print). Anyway. if you are using OneDrive for Business you shouldn't need a filter. In my testing the Modified trigger only fires after a file has been modified, not when it is first created.
That's okay! Thank you for your assistance, I've not had a chance to look at this since monday but I'm back on it now. The issue I was having before was that if I created a new document and saved it directly to the folder (the one with the trigger) it would automaticallty trigger the Flow and move it to the new folder. Maybe I took a wrong step along the way so I'll create a new flow from scratch and try it!
Hi, hope you're well.
Sorry I've not been able to get back to you since wednesday.
I ran some tests and it appears to work as expected in the OneDrive Windows Explorer Filder set up, I can drag an item to the 'Pending' folder and it will stay in there as it's a copy and has not been modified, the last modified date is the same as before.
However if I do it in the OneDrive client, even by clicking and dragging the document it changed the last modified date to when I performed this action & therefore triggers the flow.
Is there a way around this?
The behavior you are seeing using the OneDrive Sync client is what I would expect. The file is created on the Desktop and then synced to OneDrive by the OneDrive client. That sync counts as a modification. I don't really see an easy way to get around that since it actually does count as a modification.
Thank you for your help. I'll have to see if I can get people to use the Windows Explorer tool.
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!
User | Count |
---|---|
45 | |
42 | |
37 | |
36 | |
23 |
User | Count |
---|---|
42 | |
31 | |
28 | |
28 | |
28 |