Forum Discussion

Oliver Kiesslich's avatar
Oliver Kiesslich
Copper Contributor
Nov 02, 2016

Getting the Version number of a SharePoint document with Flow

Hi Everyone, recently I tried to setup a flow that reacts on a file change and reads the version of a document. I would like to check if this is a major version copy it to another library. Now I have seen the Action "Get File Metadata" - but this does not give me the version of the file. Is there any way to get the version of the file that got changed?

  • Glenn Prince's avatar
    Glenn Prince
    Copper Contributor

    Heya, I know this is a bit of an old post but I had a similar experience while I was trying to mock up a prototype for integration between SharePoint and a record keeping system. To get around it you can send a HTTP request to the SharePoint API with the file identifier to retrieve the list of versions, get the latest version and make a decision on that. If your still interested you can find a full walk through on my blog here: Creating a Version Monitoring Flow in SharePoint

    Cheers, Glenn.

    • Allan Savage's avatar
      Allan Savage
      Copper Contributor

      Thanks for this Glenn - exactly what I needed i.e. to be able to pass up the version number to an approver when submitting a controlled document, so that the document and version is all part of an auditable process.  Cheers.

    • Kushan Lahiru Perera's avatar
      Kushan Lahiru Perera
      Brass Contributor

      Hello,

       

      Your blog post is really awesome and interesting.

       

      I would suggest to refer below endpoint of SharePoint where you could reduce the number of steps. 

       

      GET: Minor Version
      /web/getfilebyserverrelativeurl('/Shared Documents/filename.docx')/MinorVersion

      GET: Major Version
      /web/getfilebyserverrelativeurl('/Shared Documents/filename.docx')/MajorVersion

      If you still need both Major and Minor version numbers, I may go with your way since multiple HTTP requests will reduce the performance of workflow. 

       

      Need to read more?

      Find below reference from Microsoft MSDN

      https://msdn.microsoft.com/en-us/library/office/dn450841.aspx

       

      Kushan Perera | Microsoft MVP

      Web: kushanperera.com

      Blog: blog.kushanperera.com

      • Glenn Prince's avatar
        Glenn Prince
        Copper Contributor

        Hi,

         

        Thanks for the feedback. When I was originally looking into this those endpoints didn't exist. For what I am using it for it is more useful to get both components of the version number but I will have to update the article to include some notes about those endpoints.

         

        Glenn

    • TerranIncognito's avatar
      TerranIncognito
      Copper Contributor

      Glenn Prince 

       

      God bless you, sir. This is a wonderful Flow, and you are very clear in your explanation of how to set it up. Well done, and much appreciated!

  • Davy Loose's avatar
    Davy Loose
    Brass Contributor

    Hi Oliver,

     

    At the moment you can't get the version number of a document using Flow. Flow only returns a select number of properties for a document. That means you also can't use custom metadata. 

     

    I'm not sure when Microsoft is going to add this fuctionality to Flow. 

Resources