SharePoint workflow to move a document to a folder
Learn how you can use a SharePoint Designer workflow to move a document from a SharePoint document library on one SharePoint site to a specific folder in a document library on another site in SharePoint 2013.
In a previous article, I showed you how you can use a SharePoint Designer workflow to move a document from one SharePoint document library to another.
However, because you cannot select a specific folder to copy a document to from within a SharePoint Designer workflow, this technique does not allow you to move a document to a folder in another SharePoint document library.
In addition, cross-site movement of documents is not possible; you are limited to moving documents between document libraries on the same site.
The Content Organizer feature in SharePoint creates metadata-based rules that move content submitted to a site to the correct library or folder.
While I think Microsoft intended the Content Organizer feature to be used for records management in SharePoint, you can "abuse" this feature to be able to move documents to folders within a SharePoint document library and also to move documents between SharePoint document libraries on two different sites in the same SharePoint site collection.
This article shows you how to create a SharePoint site and enable it to receive documents, and then afterwards create a SharePoint Designer workflow to be able to send documents to that site using a SharePoint workflow.
Create a SharePoint site to which documents can be moved
Before you can send documents to a SharePoint site in a site collection, and have the documents routed to a particular SharePoint document library and folder on that site, you must enable the Content Organizer feature as follows:
- In SharePoint 2013, if you do not already have a SharePoint site, create one by going to the Site Contents page and clicking new subsite. You can create a normal site based on the Team Site template. In this article, the site will be called moveddocs.
- Once you have created the site, select Site settings from the Settings menu (the gear icon in the top-right corner).
- On the Site Settings page under Site Actions, click Manage site features.
- On the Site Features page, click Activate behind the Content Organizer feature. Once you have activated the Content Organizer feature, a SharePoint document library named Drop Off Library will be automatically created, and two links to manage organizing content (Content Organizer Settings and Content Organizer Rules) will appear under the Site Administration section on the Site Settings page.
The SharePoint site you created is now ready to receive documents sent to it. However, to be able to route documents that are based on specific metadata to specific folders or libraries, you must create content types that have properties that can be monitored by the content organizer when a document is sent to the site.
Create a SharePoint content type to move documents to a folder on a site
The same way you can create SharePoint site content types to manage sending documents to a SharePoint Records Center, you can create them to send documents to a normal site.
- Follow the steps outlined in Create a site content type for use on multiple SharePoint sites of Create a content type for document routing to a Records Center to create a content type that can be used on two different sites in the SharePoint site collection.
- If you do not already have a site from which you will be sending documents, create one, and create a SharePoint document library on it.
- Associate the site content type with the document library you just created as explained in Associate a SharePoint site content type with a document library of Create a content type for document routing to a Records Center.
- Navigate to the moveddocs SharePoint site and create a new SharePoint document library named MyDocLib.
- Associate the site content type with the MyDocLib document library as explained in Associate a SharePoint site content type with a document library of Create a content type for document routing to a Records Center.
- Navigate to the MyDocLib document library, click Files > New > New Folder, and create a new folder named Folder1. You will be using a SharePoint Designer workflow later to move documents to this folder based on metadata rules.
- On the moveddocs SharePoint site, navigate to the Site Settings page, and then under Site Administration, click Content Organizer Rules.
- On the Content Organizer Rules page, create a new rule as described in Configure document routing in a SharePoint Records Center of Create a content type for document routing to a Records Center, but then change the Destination to point to Folder1 instead of the root folder of the document library. So enter
in the Destination text box on the New Rule page.
The moveddocs SharePoint site is now ready to receive documents and move them to the Folder1 folder in the MyDocLib SharePoint document library if they satify the conditions you specified. In this case, if the Country/Region property of a document has a value of United States, the document will be moved to the Folder1 folder; otherwise it will be moved to the root folder of the Drop Off Library SharePoint document library.
Next, you will be creating a SharePoint Designer workflow users can use to move documents to the folder on the moveddocs SharePoint site.
Create a SharePoint workflow to move a document to a folder on another site
- In SharePoint Designer 2013, create a new list workflow that runs on the SharePoint document library that contains the documents you want to move to a folder that is located in a SharePoint document library on another site. Ensure that you select SharePoint 2010 Workflow as the Platform Type.
- Add a Send Document to Repository action to the workflow, and configure it to say:
Submit File using Move to http://win-a5pj1269tfk/moveddocs/_vti... with moved to folder (Output to Variable: submit file result)
where you must use the String Builder dialog box to set this destination router in the workflow action to be equal to the full URL of the officialfile.asmx web service for the SharePoint site on which the folder is located to which you want to move the document, for example:
Or if you have stored the URL in a workflow variable/parameter or in a field in a list or library, you could also perform a lookup to find that value and use it in the workflow action. Here, moveddocs is the SharePoint site on which a document library named MyDocLib is located that contains a folder named Folder1 to which documents will be moved if they satisfy certain conditions; otherwise they will be moved to a document library named Drop Off Library on the moveddocs SharePoint site.
- Publish the workflow to SharePoint.
In SharePoint 2013, navigate to the SharePoint document library to which you associated the workflow and add a couple of documents to it. Ensure that one of those documents have its Country/Region property set to United States, since the content organizer rule that was set up will be looking at this property and its value to move documents to the Folder1 folder on the moveddocs SharePoint site.
Manually start the workflow on one of the documents. Once the workflow has run and completed, navigate to the MyDocLib document library on the moveddocs SharePoint site, open Folder1, and verify that the document was moved to the folder. If the document you moved did not have its Country/Region set to United States, it should be located in the Drop Off Library SharePoint document library.
Note that you can also create a custom action on the SharePoint document library that contains the documents to move to the folder on the other site, like is described in Create a custom action to move a document to a SharePoint Records Center via a workflow of Move a document to a SharePoint Records Center via a workflow.
- SharePoint Designer workflow: Move a document from one library to another
- Move documents from one library to the next in SharePoint 2010 using Open with Explorer
- Create a content type for document routing to a Records Center
- Manually move a document to a Records Center in SharePoint 2013
- Move a document to a SharePoint Records Center via a workflow