cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Impactful Individual
Impactful Individual

Copy file to location, maintaining version history

Hi

 

Is it possible to use flow to copy a file to another document library and maintaining full metadata and version history?

If i can't maintain version history of the file can i atleast extract the version from the original file and use that number to display what version it is?

 

  • User publish a major version in a sharepoint library.
  • Flow will copy the approved file to another location (File at new location alwasy gets version 1.0 at the moments even if the published file is version 8.0.

 

I understand while using copy i create a new file the new file then gets version 1.0 because it is a a new file. But i need the version history of the orginal file to match. 

 

If i can't get the version history with me, can i atleast display the correct version number? Maybe get the version history number fomr using a "Send HTTP Request" and then save the version number as a variable and then use another "Send HTTP Request" Patch to get the version number into the version column of the file i copied.

 

I know i can get the version history of the orginal file using this flow.

https://sergeluca.wordpress.com/2018/07/31/get-the-version-of-a-sharepoint-list-item-with-flow/

 

But how can i patch it into the new location where the file was copied to? 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Copy file to location, maintaining version history

Hi @JimmyWork ,

 

As you mentioned, if Copy File, the version information of the file will not be maintained.

You have come up with a more reasonable solution, use a Column to record the version information of the source file, and record it to the Destination File.

 

Please first use Send an HTTP request to SharePoint action to get the version number of the source file, and then use Update file properties action to update the specified Column.

 

Image reference:11.PNG

Expression:

body('Send_an_HTTP_request_to_SharePoint')['d']['Odata__UIVersionString']

Please take a try.

 

Best Regards,

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

View solution in original post

6 REPLIES 6
Highlighted
Community Support
Community Support

Re: Copy file to location, maintaining version history

Hi @JimmyWork ,

 

As you mentioned, if Copy File, the version information of the file will not be maintained.

You have come up with a more reasonable solution, use a Column to record the version information of the source file, and record it to the Destination File.

 

Please first use Send an HTTP request to SharePoint action to get the version number of the source file, and then use Update file properties action to update the specified Column.

 

Image reference:11.PNG

Expression:

body('Send_an_HTTP_request_to_SharePoint')['d']['Odata__UIVersionString']

Please take a try.

 

Best Regards,

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

View solution in original post

Highlighted
Helper I
Helper I

Re: Copy file to location, maintaining version history

@v-bacao-msft  in my case sourcefile version option not showing in my updatefile properties action. ihave Spversion but update Spversion cant change the version of file.updatefile.PNG

Highlighted
Impactful Individual
Impactful Individual

Re: Copy file to location, maintaining version history

@HN 

 

I did it like this.
Use following body for JSON Scheme, then you will get the following dynamic content to pick from. MinorVersion, MajorVersion, UIVersion and so on. You can use that to update the field.

{
    "type": "object",
    "properties": {
        "d": {
            "type": "object",
            "properties": {
                "__metadata": {
                    "type": "object",
                    "properties": {
                        "id": {
                            "type": "string"
                        },
                        "uri": {
                            "type": "string"
                        },
                        "type": {
                            "type": "string"
                        }
                    }
                },
                "Author": {
                    "type": "object",
                    "properties": {
                        "__deferred": {
                            "type": "object",
                            "properties": {
                                "uri": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                },
                "CheckedOutByUser": {
                    "type": "object",
                    "properties": {
                        "__deferred": {
                            "type": "object",
                            "properties": {
                                "uri": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                },
                "EffectiveInformationRightsManagementSettings": {
                    "type": "object",
                    "properties": {
                        "__deferred": {
                            "type": "object",
                            "properties": {
                                "uri": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                },
                "InformationRightsManagementSettings": {
                    "type": "object",
                    "properties": {
                        "__deferred": {
                            "type": "object",
                            "properties": {
                                "uri": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                },
                "ListItemAllFields": {
                    "type": "object",
                    "properties": {
                        "__deferred": {
                            "type": "object",
                            "properties": {
                                "uri": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                },
                "LockedByUser": {
                    "type": "object",
                    "properties": {
                        "__deferred": {
                            "type": "object",
                            "properties": {
                                "uri": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                },
                "ModifiedBy": {
                    "type": "object",
                    "properties": {
                        "__deferred": {
                            "type": "object",
                            "properties": {
                                "uri": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                },
                "Properties": {
                    "type": "object",
                    "properties": {
                        "__deferred": {
                            "type": "object",
                            "properties": {
                                "uri": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                },
                "VersionEvents": {
                    "type": "object",
                    "properties": {
                        "__deferred": {
                            "type": "object",
                            "properties": {
                                "uri": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                },
                "Versions": {
                    "type": "object",
                    "properties": {
                        "__deferred": {
                            "type": "object",
                            "properties": {
                                "uri": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                },
                "CheckInComment": {
                    "type": "string"
                },
                "CheckOutType": {
                    "type": "integer"
                },
                "ContentTag": {
                    "type": "string"
                },
                "CustomizedPageStatus": {
                    "type": "integer"
                },
                "ETag": {
                    "type": "string"
                },
                "Exists": {
                    "type": "boolean"
                },
                "IrmEnabled": {
                    "type": "boolean"
                },
                "Length": {
                    "type": "string"
                },
                "Level": {
                    "type": "integer"
                },
                "LinkingUri": {
                    "type": "string"
                },
                "LinkingUrl": {
                    "type": "string"
                },
                "MajorVersion": {
                    "type": "integer"
                },
                "MinorVersion": {
                    "type": "integer"
                },
                "Name": {
                    "type": "string"
                },
                "ServerRelativeUrl": {
                    "type": "string"
                },
                "TimeCreated": {
                    "type": "string"
                },
                "TimeLastModified": {
                    "type": "string"
                },
                "Title": {
                    "type": "string"
                },
                "UIVersion": {
                    "type": "integer"
                },
                "UIVersionLabel": {
                    "type": "string"
                },
                "UniqueId": {
                    "type": "string"
                }
            }
        }
    }
}

2019-09-20 13_33_17-Edit your flow _ Microsoft Flow.png2019-09-20 13_35_12-Edit your flow _ Microsoft Flow.png

Highlighted
Helper I
Helper I

Re: Copy file to location, maintaining version history

@JimmyWork  i want to update Vesrion Field in Sharepoint which Sharepoint gives us by default  not that fields which created by users in Sharepoint document Library.

Highlighted
Impactful Individual
Impactful Individual

Re: Copy file to location, maintaining version history

@HN I dont think you can do this. I had to create a new column and write version info to that column. I dont belive we ever can overwrite the version number without causing issues.

 

My setup is that if a major version is published it is copied to another location where all users can view it. For me to see what version this is i create the extra column. Versions field standard sharepoint will not show the same info.

 

You can save the version number to the document.

https://www.glennprince.com/blog/creating-a-version-monitoring-flow-in-sharepoint/

 

 

Highlighted
Helper I
Helper I

Re: Copy file to location, maintaining version history

Thannks for respons but i want to do that i asked above. Thanks for your time 

Helpful resources

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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!

Users online (9,255)