web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Move File action for S...
Power Automate
Unanswered

Move File action for SharePoint does Copy/Delete in some API RuntimeURL = does not keep file ID nor Version History

(0) ShareShare
ReportReport
Posted on by 10

Hello Community,

 

We need to move files from the root of a library into folders based on the lifecycle of a document. When it's in Draft the file is located in ComplianceDocuments root. When the document is sent out for approval it gets moved into ComplianceDocuments/ReadOnly. When the document is obsolete and needs to be archived it gets moved into ComplianceDocuments/Archived. As there are linked Document Change Requests and Training Receipts we need to keep the same SharePoint ID when moving the files within the same document library. Works fine with the Library action button "Move To...".

 

We have now identified that the SharePoint Action "Move File" in Power Automate does not behave the same across the different API/RuntimeURLs.

 

Used library : default created Documents library (Shared Documents)

Folder : ReadOnly

Version control : activated 1.0, 2.0, 3.0

Approval : not activated

Flow :
- Trigger: For a selected File (tested as well When a File is created or modified (properties) and When an item or file is modified)
- Get File properties
- Move File with option "Replace" (tested as well "New Name")

 

When a Flow runs on :

https://flow-apim-europe-001-northeurope-01.azure-apim.net/apim/sharepointonline

https://unitedstates-002.azure-apim.net/apim/sharepointonline

It mimics exactly what a user would do in the library list view experience with the action button "Move To" within the same library.

File keeps the SharePoint ID and all Version History.

 

When the same identical Flow on the box Documents library runs on :

https://flow-apim-europe-001-westeurope-01.azure-apim.net/apim/sharepointonline

https://flow-apim-msmanaged-na-westus2-01.azure-apim.net/apim/sharepointonline

https://flow-apim-msmanaged-na-centralus-01.azure-apim.net/apim/sharepointonline

https://australia-001.azure-apim.net/apim/sharepointonline

 

The result in the ReadOnly folder is a file with at least an increment of 2 in the ID and a deleted file in the Recycle bin. Version History starts at 2.0 (1.0 create of the file and 2.0 update of the properties). It looks like Flow understands the Move File Action as a bundle of "Copy File" and "Delete File".

 

We are looking into the HTTP route now, but it's quite a hassle for what should be an easy 1 step action 😉

 

Or is there an option to switch a Flow Owner's environment ?

 

Thank you,
Belinda

 

bschoeni_0-1631207343462.png

Before running the Flow :

bschoeni_1-1631207403363.png

 

Result : 

bschoeni_2-1631207428480.png

 

bschoeni_3-1631207441312.png

 

Where to find API - RuntimeURL : on an executed flow open the trigger and click in Inputs to "Show raw inputs" :

bschoeni_0-1631208250025.png

 

 

Categories:
I have the same question (0)
  • terryitec Profile Picture
    4 on at

    I'm also having the same issue as we will archive the document like you. 
    However, SharePoint treats it as copy and delete, then all the versioning is gone and a huge list of deleted logs and files is moved to recycle bin which is not what I want.

     

    Any ways to move the files to another document library without creating a lot of delete records and files in recycle bin ?

  • bschoeni Profile Picture
    10 on at

    Hi @terryitec ,

     

    The action Send an HTTP request to SharePoint has worked well for us to move files from one folder to another in the same library keeping full version history. 

     

    I just tested if it would work as well to move a file from a library A to A-Archived. I used the trigger "For a Selected File" in SharePoint and then Get the file properties. It does go through, but would update all property changes in todays version. So you would lose time stamp when properties got changed.

     

    Create two Compose actions : 

    - Current Path: need to type the /sites/SiteName/ and select from Dynamic Values the Document Full Path

    - Destination Path: need to type the /sites/SiteName/DestLibraryName/ and select from Dynamic Values the Document File Name with extension

     

    The Uri I use in the print screen is : 

    _api/web/getFileByServerRelativeURL('OutputCurrentPath')/moveTo(newUrl='OutputDestinationPath')}',flags=1)

     

    If you work with Folders then you will have to split the the Folder Path to extract the folder structure. Create 2 Compose : 

    - SplitPath :  Expression = split(triggerBody()?['{Path}'],'SourceLibName')
    - Compose relative Folder Path : Expression = outputs('SplitPath')[1]
    In this case the Compose above with Destination Path would be with no / as it comes from the compose
    .../sites/SiteName/DestLibraryNameOutputComposeRelativeFolderPath/File Name with extension
     
    There are certainly more advanced solutions out there and less static, but for my need this was plenty 🙂
  • terryitec Profile Picture
    4 on at

    For the folder, do you mean that I should list out all the paths of files and folders under the source folder that I should move and submit the HTTP request on each file and folder? 
    My flow is moving a set of documents when it needs to archive to the archive library. 
    Then my flow is using copyfolder to move to another library, the versioning is the not main concern to me but the deleted logs and files in recycle make the audit job harder. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard