Introduction
The Content Organizer feature is a component of the Enterprise Content Management workload in SharePoint 2010. As you can imagine, there are many pages/posts/questions about the feature on the internet. If you need to learn a bit more, I would suggest the planning documentation on TechNet and the development overview on MSDN.
Content Organizer and Document Id service
In most of the deployments that I have been involved with, the content organizer is used in conjunction with the Document ID service. Users are directed to the Drop Off library to upload documents and to provide the related metadata. Base on that metadata, the document is moved from the Drop Off library to the appropriate location. To help the contributors find the information later, the Document Id service is used to assign a unique identifier to the document which is reported as a URL. (Much like the URL shortening services on the internet like t.co and bit.ly.)
In addition to the well-known URL, SharePoint provides a web part to look up a document by its Document Id. If the Id is known, then the location of the document does not matter. The Document Id service will locate the document.
The missing piece
There is one piece missing in this picture. Ben Curry mentioned this to me during the beta timeframe, and everyone I have mentioned it to since agrees: Why is there no web part to provide the submission to the Drop Off Library?
For document libraries that are targets of Content Organizer rules, the upload link will redirect to the Drop Off Library. Contributors can also navigate directly to the Drop Off library and click upload. But, in the scenario where all the libraries in the site use the Content Organizer, why force the contributor to click into a library? In reality, they could choose any library they want and the document ends up in the correct place.
So, I finally created the web part that Ben calls the "Easy Button": the Content Organizer Link web part.
Behind the scenes of the Content Organizer
Activating the Content Organizer feature in a site will implement some changes to theSPWeb object. The SPWeb.CustomUploadPage property is set to the UploadEx.aspx page. The code-behind for this page will inspect the Content Organizer routing rules to determine if the current library is a target of a rule. If so, then the "current list" is switched to the Drop Off library and the upload happens there.
In addition, there are a few properties added to the SPWeb that are surfaced via the EcmDocumentRoutingWeb class. Specifically, the IsRoutingEnabled property indicates if the Content Organizer is in use and the DropOffZone property points to the SPList object that represents the Drop Off library. Figure 1 shows these properties of the SPWeb and EcmDocumentRoutingWeb in PowerShell.
Figure 1 - Additional Properties of SPWeb upon activation of Content Organizer feature
Content Organizer Link Web Part
The Content Organizer Link Web Part (COLWP) is designed to streamline the contributor's upload experience. The web part determines the URL of the new item form in the Drop Off Library (Figure 2) and opens that URL using the SharePoint dialog framework.
The web part at its core is just an ASP.NET hyperlink control (Figure 3). The Hyperlink allows for either text or an image for its display. The latter is perfect for Ben to use an image to communicate his wishes. To aid in the entry of the Image URL, I copied the interface from the Image Viewer ToolPart (an EditorPart in ASP.NET 3.5). The editing interface is shown in Figure 4.
Figure 2 - Code to determine the URL of the Drop Off Library
Figure 3 - Code to create the Hyperlink to the Drop Off Library
Figure 4 - Editor interface to Content Organizer Link web part
Contributors who click the link see a familiar experience for uploading their document. The custom Link Text specified in the web part is carried over to the dialog, as shown in Figure 5.
Figure 5 - Dialog box with consistent title
Interesting Coding Techniques
One of the primary reasons I write these community projects and articles is to learn about and illustrate interesting coding techniques. There are quite a few utilized in this project:
- Loading script files using Script on Demand. (Thank you Waldek.)
- Editor Parts to extend the web part property entry experience. (Thank you Wictor.)
- Conditional compile/references based on the Sandbox setting of the project. (This one is all me!)
- Use of the EcmDocumentRoutingWeb class. (Not much of this on the internet. See Figure 2.)
- Cleaning up modules (files) from the content database upon Feature Deactivation.
Conclusion
The complete solution is available on CodePlex at https://spcontentorglink.codeplex.com/ GitHub at https://github.com/pschaeflein/SPContentOrgLink. It is a simple solution, without enterprise features like logging and caching. The default download is a farm solution, due to the use of the ECM features.