How to create Content Organizer rules using Workflow or PowerShell
I had a need recently to create many content organizer rules dynamically via Nintex workflow and I couldn't find a pre-canned method for doing so. I eventually figured a way and wanted to share in case someone else needs this. Even though I created the rules using workflow, the rules could also have been created using powershell.
Scenario:
The scenario that led me down this path was that I was designing a SharePoint 2010 records management solution where documents submitted by users had to be routed to a folder created specifically for that user. In other words, the solution had to flow as follows:
1. User submits document to record library
2. Content organizer timer job runs to route document if a Content Organizer rule exists
3. Periodically, a Nintex site workflow would kick off and check to see if documents were still in the drop off library. If documents were still in the drop off library, the workflow would create a folder for the submitting user and a content organizer rule to route documents that that folder.
So now that we understand the scenario, I'll go ahead and outline how to create the content organizer rules dynamically. The steps below assume that a record center site collection has been created.
- Make "content organizer rules" list visible by running the following powershell:
$site = get-spsite https://urlToRecordCenter
$list = $site.rootweb.lists[“content organizer rules”]
$list.hidden = $false
$list.update()
2. Make Condition XML field visible:
$field = $list.Fields.GetFieldByInternalName(“RoutingConditions”)
$field.hidden = $false
$field.update()
3. Now use workflow to create the content organizer rules dynamically. The Nintex Create Item action was configured as follows.
Note: Some of the values below (eg itemCreator) won’t translate directly to other environment because they were variable names I used in other parts of the workflow. The idea I’m mostly trying to convey is that these are the fields that will need to be set at a minimum to have a functioning content organizer rule.
To figure out what applies to you, I recommend creating a rule through the UI first and then copying the values over to your workflow design surface.
- Field: Title => Rule Name
- Content Type: Rule
- Field: Active => Yes
- Field: Priority => 9
- Field: Target Path => webRelativeURL/Records/DestinationFolderName
- Field: Route to External location => No
- Field: Submission Content Type => Document
- Field: Condition XML => <Conditions><Condition Column="ada5b8d0-79d8-48ae-a68e-6181cde84656|UserName1|UserName" Operator="IsEqual" Value="itemCreator" /></Conditions>
- Field: Target Library => Records Library
- Field: Target Folder => itemCreator
- Field: Properties used in conditions => username
- Field: Rule name => Rule for ItemCreator