Hi All.
I am trying to build a Flow that will automatically rename the file in a Sharepoint Document Library when some of the file properties change.
The properties may change as a result of a direct edit of Doc Library columns, or by editing the file online (it has a number of Doc Parts linked to respective columns).
For instance, I want my file to be called <Titile>-<Version>-<Status> (retaining the extension) and when the version changes the file gets renamed. Same should happen automatically for the uploaded files.
I know that there is no "Rename" or "Move" file action for Sharepoint. Neither can one rename the file using the "Update File Properties" (the most logical way to me). The only solution is then to Copy and then Delete the file.
Here the fun begins...
There are two mutually types of triggers I have tried:
* "When a file is created or modified" - this one provides all the values and columns, but, for instance, does not provide the File Path that the Copy/Delete actions want.
* "When a file is created or modified in a folder" - this provides all necessary file identifiers for Copy and Delete, but does not provide column values and other metadata, and none of the values it returns are good for "Get File Properties" action ID field (they are simply not displayed as possible inputs there).
So, it seems there is not way to use both in the same flow w/o some advanced level woodoo magic such as oDATA requests (maybe).
Question 1: Is that right or there is a way to bridge between the two?
In trying to find such way I have found that "When a file is created or modified (properties only)" trigger provides an Identifier field. Which, for a file Document.docx in a Document Library called __TestDocLib looks like "TestDocLib%252fDocument.docx"
Thus, I am trying to leverage this in my flow (site address removed).
[For some reason I can't insert the picture - the web site is throwing errors]
COPY FILE Action:
* Site address: [my site]
* Source file path: [Identifier]
* Destination file path: [Folder Path]/[Name]_[iVersion]
* Overwrite: False
iVersion is one of my columns that I have created for testing. All the values are received from the previous step ("When a file is updated of created (properties only" trigger).
By the way
Question 3: How do I access file extension when copying the file? String manipulations?
However, the flow triggers an error in the Copy File action
The file /sites/<mysite>/TestDocLib%2fDocument.docx does not exist.
This is very interesting, as if I take this URL (add the hostname prefix, of course, we are using SP Online) and paste it in by browser - I can download the file!
Question 3: What am I doing wrong?
Additional error details below, as well as a couple more related questions
Question 4: How to make Flocw check for trigger more often than once/5min or how to make SP Online send a notification to Flow to execute a flow?
!Many thanks for any guidance that will help me progress!
COPY Files - Inputs
* Site address:https://[company].sharepoint.com/sites/[mysite]
* Source File Path: TestDocLib%252fDocument.docx
* Destination File Path: TestDocLib//Document-1.0.0-001
* Overwrite: False
COPY Files - Outputs
* Status code: 404
* Headers: (nothing insteresting here)
* Body
"status": 404,
"message": "The file /sites/[mysite]/TestDocLib%2fDocument.docx does not exist.\r\nclientRequestId: [SNIP]",
"source": "https://[mydomain].sharepoint.com/sites/[mysite]/_api/web/GetFileByServerRelativePath(decodedUrl=@p)/Etag?@p='%2fsites%2[mysite with URLencode]%2fTestDocLib%252fDocument.docx'",
"errors": [ "-2130575338", "Microsoft.SharePoint.SPException" ]