Moving Documents with Version History

  • 23 March 2016
  • 8 replies
  • 43 views

Badge +3

I will be creating a document library that will have several thousand documents added to it each month, and I will need to move documents to another library while preserving the version history.  Has anyone implemented the use of a Web Request action to call author.dll in order to move documents from on Doc Lib to another with the version history?  I read Vadim Tabakman’s great post describing how to do this, but I am hesitant to use this on a large scale implementation.

References:
This article makes it pretty clear that Nintex Workflow doesn’t have the ability to move / copy documents with the version history.
https://community.nintex.com/message/18317

This is a product improvement request that was created in July 2014.
https://nintex.uservoice.com/forums/229405-1-nintex-workflow-for-sharepoint/suggestions/6183646-nintex-workflow-action-to-move-documents-across-sh

The product improvement request contains the following comment: “Note: I have tested it with our SP 2013 and the fact that it does not work was verified by Nintex Support. Hope this helps someone in the future on SP 2013 on-premises.”.

This is Vadim Tabakman’s article:
http://vadimtabakman.com/nintex-workflow-move-documents-and-preserve-version-history.aspx

I have executed this successfully with a couple of documents in a test environment, but I’m not sure if I want to commit to using this for an enterprise production solution.  What if the next version of SharePoint doesn’t support this dll?

Has anyone used this solution in a large scale production environment?  Thanks!


8 replies

Badge +4

Steve,

Since nobody answered, let me try answering your question.

I do not think there is any metrics around whether it would be feasible to do what you want to do with thousands of documents. You might need to set up a pilot with some performance counters on SharePoint and also on the servers themselves and watch the service performance, and the load on CPU etc.,

In my opinion, you might want to look into a more migration focused product than nintex, like ShareGate ​. ShareGate is pretty nifty tool and I have used it successfully for migrations. They also support powershell, so you could just schedule the migration for a specific time each month.

Hope that helps!

Badge +3

Thanks for the comments, Prasanna - I appreciate it!

Badge +3

Hi, Mathieu -

Sorry I didn't respond to this earlier - the mail notification ended up in my junk mail, and I just saw it yesterday.

Thanks for the suggestion.  I was not looking for a purchased third party solution for this - I was hoping I could use some feature of Nintex Workflow to do this, but I'm not certain that I can rely on what I have found so far.

To complete this thread, what I ended up doing was writing a PowerShell script to move the documents from the source library to the target library.  The script uses a CAML query to identify the candidate items, and the workflow history is preserved when the files are moved.  The script is then scheduled to run periodically.  The disadvantage is that I needed to introduce a server based component into the solution (the PS script), but it seems to do the job, and I believe this is reliable.

Thanks to everyone who contributed to this post.

Badge

Hi Steve

Is it possible to share the script?

I have a similar requirement and I see Nintex has not release a move action.

Badge +3

Hi, Rego - I have included the relevant parts of the script here.  There is more to the script that is outside the scope of the issue, but this should do it.  I needed to maintain the folder structure in the target list, so this may be more complicated than you need.  The most important line is the last one - the "File.MoveTo" statement.  It looks like the formatting got lost when I pasted the code , so the indenting is gone.  Hopefully this is enough for you to make it work.  Good luck!

# Get the Source and Target lists

$SourceList = $Web.Lists["Reconciliation Docs"]

$TargetList = $Web.Lists["Archived Docs"]

# Get all items where Status = Approved and Approved Date less than Archive Threshold Date

$CAMLQuery = "<Where><And><Eq><FieldRef Name='GLStatus' /><Value Type='Choice'>Approved</Value></Eq><Lt><FieldRef Name='GLApprovedDate' /><Value Type='DateTime' IncludeTimeValue='TRUE'>$ThresholdDateStr</Value></Lt></And></Where>"

$SPQuery = new-object Microsoft.SharePoint.SPQuery

$SPQuery.ViewAttributes = "Scope='Recursive'" # Needed to include folders in the library

$SPQuery.Query = $CAMLQuery

$SourceItems = $SourceList.GetItems($SPQuery)

# Move each file to the destination folder

foreach ($SourceItem in $SourceItems) {

# Get the Source File

$SourceFile = $Web.GetFile($SourceItem.File.URL)

# Try to get the Target Folder

$TargetFolderName = $SourceItem.File.ParentFolder -replace $SourceList.RootFolder, $TargetList.RootFolder

$TargetFolder = $TargetList.ParentWeb.GetFolder($TargetFolderName);

# If the Target Folder doesn't exist, create it recursively as deep as needed

if ($TargetFolder.Exists -eq $false) {

$TargetFolderNameArr = $TargetFolderName.Split("/")

$FolderPath = $TargetList.ParentWebURL

foreach ($SubFolder in $TargetFolderNameArr) {

$FolderPosition = $FolderPath

$FolderPath = $FolderPath + "/" + $SubFolder

$TargetFolder = $TargetList.ParentWeb.GetFolder($FolderPath);

if ($TargetFolder.Exists -eq $false) {

$TargetFolder = $TargetList.Folders.Add($FolderPosition, [Microsoft.SharePoint.SPFileSystemObjectType]::Folder, $SubFolder)

$TargetFolder.Update()

}

}

}

# Move the Source File to the Target List - "MoveTo" retains Version History

$SourceFile.MoveTo($TargetFolder.Url + "/" + $SourceFile.name)

}

Badge

Thanks Steve

Will try it out and let you know.

Much appreciated.

Sent from Samsung tablet

Badge

Hi Steve

Any Ideas.

I have tried using a UNC Path and full url to the destination library still no luck.

Exception calling MoveTo with one argument(s)

Badge +3

Hi, Rego - For debugging, I would try to hard code everything as much as possible to make sure it is working as expected, then use the variables.  Get a handle on a hard coded file name at the root of the source library and move it to the root of the destination library - all hard coded.  When that works, then start adding back the variables one at a time to see where it might be failing.

Reply