As described in the subject, I want to know does it include renaming a file? And if it is, how can I get the file's previous name? I created a flow with "When a file is modified (Properties only)" but when I changed a file name, the trigger isn't fired.
does it include renaming a file?
Both the When a file is modified (properties only) [OnUpdatedFilesV2] and When a file is modified [OnUpdatedFileV2] Triggers should work on both file editing and renaming - so in other words, for both triggers, editing the file contents, or even just renaming the file without editing the file contents, should fire both triggers in both cases.
I just tried it as well right now with the OneDrive for Business Connectors and Triggers, I was able to get both versions of the Triggers to fire when renaming the file, and that's even when the file contents were not edited.
When editing a file contents, and also, when renaming a file without editing the file contents, I was able to get the triggers to fire in both cases.
There were some cases where I did not notice the triggers firing, but saw it appear in the Flow Run history some time later - try seeing if waiting 5 to 15 minutes helps. It is possible to believe the trigger is not working because when you happened to test it, the one fired for editing the file but the one for renaming it fired later. This happened first to me and made it look like it didn't work for renaming the file, much like you write here. However, when I tested it multiple times instead of just a few times, I was able to get more misleading results that even both renaming and editing did not work. Instead, the fact is, it was because the events came in a little bit later. Sometimes the events might come in later, see if waiting a bit helps. I did not notice that renaming necessarily came in later than editing - that only happened the first time I tested - after multiple tests, I was able to get them both to come in later, making it seem like it "didn't work at all". In fact, all events eventually came in within a few minutes, both for renaming, and for editing, and in all cases.
The When a file is modified (properties only) and When a file is modified should both work, and should both fire when the file is modified. Since renaming is a kind of modification, it should work, and I just tested it and it also works.
Renaming the file should fire both versions of the trigger When a file is modified (properties only) and When a file is modified
Actually, "properties only" is not referring to renaming the file to cause the trigger to fire, that is referring to something else.
The words "properties only" in the When a file is modified (properties only) in the name of the trigger is not referring to properties that are the cause of the change, such as changing of the file name to trigger it (despite this being in the title of the trigger in parentheses). Instead, it is referring to what the trigger will provide in the payload in When a file is modified (properties only) [OnUpdatedFilesV2] as opposed to When a file is modified [OnUpdatedFileV2]
In fact, both versions of the trigger should work for rename, because the word modified appears in both versions of the trigger title. The "properties only" actually means the following instead:
Specifically, it is that one trigger provides the File Content itself in the payload, whereas the other (the "properties only" one) does not, and provides, as it says in its name, "properties only". In any case, both of these triggers should fire when the file is renamed in OneDrive, even if the contents are not edited
You can check this difference on the "When a file is modified" [OnUpdatedFileV2] - the one without the properties parenthetical:
When a file is modifiedThis operation triggers a flow when a file is modified in a folder. Files larger than 50 MB will be skipped and not returned by this trigger. [emphasis added]
- Operation ID:
Reason it might be skipping such big files more than 50MB is because, this trigger provides the actual File Content in the Trigger payload:
The (Properties Only) variant does not provide this.
Hence "Properties Only".
Other than this, both triggers should work even when renaming the file and not editing the contents.
Note that the name given will be the name AFTER the rename - i.e. the new name and not BEFORE i.e. the previous name. Same with the file contents, for the version of the trigger that provides contents, it is the new contents which will be provided, not the previous contents.
I do recommend for you to use the "properties only" version of the trigger, if the file name is what is important and not the contents of the file.
As for the other question:
how can I get the file's previous name?
To my awareness, there is not a way to get the previous name. You might be able to instead ask people to use specific prefix or naming convention for specific files, and only change some part of the ending when making revision. In this case it might be possible to know which file it was which was changed without knowing the previous name. It might be helpful to know more about why the previous name specifically is important to be known.
In the case it is very important to know the previous filename. I am not aware of a Connector which does it out of the box right now, but it may be possible to retrieve this information. For the moment I won't answer in detail, but this might be possible starting point: Listing versions of a DriveItem or potentially Enumerate Activities - Note: I did not test if any of these will actually return a previous filename - it might, but I did not test that - it may be for you to find that out.
In the case it is very important to get the previous filename and you would like some more detail and guidance on potential solutions for this, please share some more about your scenario just in case the previous filename is very important for your use case.
I've waited for it until now is almost 12 hours, but the flow is still not triggered after renaming a file. I'm sure that I've pointed the target folder the right way. In my case, I want to sync all my Onedrive files' activities with Google Drive, including update file content, renaming, etc... But it seems like I cannot sync the rename action. Is there any way to do it?
Check out the News & Announcements to learn more.
Participate in the Power Virtual Agents Community Challenge
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.
DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.