Content Organizer Rule (CSOM/O365)

Our client is using Office365, and we’re provisioning new sites using an Azure WebJob, which will do the necessary configuration.

One aspect they want is to do the “Content Organizer” rule.   This will mean people can upload to a document library (DropOff Lib), and it will be re-routed.  

This is for school students to submit assignment work.

After looking at CSOM code, and searching on Google for stuff like “EcmDocumentRouterRule”, I had a brain wave to just do it SIMPLE – for my fairly simple rule.

The Content Organizer from SiteSettings is just a SharePoint list – and ListItems are added.  So – looking at the REST API – there are simply a bunch of properties ;


So – it follows that I simply need to create a listitem – and it just works !


** NB.  PRIOR TO THIS, need to make sure you have turned ON the feature :

// Load the features
FeatureCollection webFeatures = clientCtx.Web.Features;

//turn on site feature for Content Organizer, will create drop off library
webFeatures.Add(new Guid(“7ad5272a-2694-4349-953e-ea5ef290e97c”), false, FeatureDefinitionScope.None);

Here’s the code, ready to copy+paste :

//only way to do within CSOM is to add the necessary listitem to “ROUTINGRULES” list  
List routingRulesList = clientCtx.Web.Lists.GetByTitle(“Content Organizer Rules”);

//get the current url, to use when defining target for rule
var web = clientCtx.Web;

var currentUrl = web.Url;
string targetLibraryUrl = currentUrl + “/SubmittedWork”;

ListItemCreationInformation routingRuleInfo = new ListItemCreationInformation();
ListItem routingRule = routingRulesList.AddItem(routingRuleInfo);
routingRule[“Title”] = “Move to Submitted library”;
routingRule[“RoutingRuleName”] = “Move to Submitted library”;
routingRule[“RoutingPriority”] = 1;
routingRule[“RoutingEnabled”] = true;
routingRule[“RoutingContentType”] = “Document”;
routingRule[“RoutingConditionProperties”] = “Content Type”;
routingRule[“RoutingTargetLibrary”] = “Submitted Work”;
routingRule[“RoutingTargetPath”] = targetLibraryUrl;
routingRule[“RoutingRuleExternal”] = false;
routingRule[“RoutingAliases”] = null;
routingRule[“RoutingRuleDescription”] = null;
routingRule[“RoutingTargetFolder”] = null;
routingRule[“RoutingAutoFolderProp”] = null;
routingRule[“RoutingCustomRouter”] = null;


Hopefully that helps with your Office365 configuration – good luck !



2 thoughts on “Content Organizer Rule (CSOM/O365)

  1. The above code doesn’t apply any of the Property-based conditions. I was wondering if you found a way to handle that logic.

    Example: Route document to library when property ‘Title’ IS NOT EMPTY.

    Property: ‘Title’
    Operator: ‘is not empty’

    Doesn’t seem like there is a solution to solve this using csom.


  2. Thanks Matt – I didn’t actually have a “RULE” – just wanted it to be done for all documents. I would try and just add the Content Rule using the UI – and then see what data is created within the list – using the REST URL…>

    The (1) is the item number – you might need to try (2) for the 2nd item in the list.

    That’s how I’d worked out the settings – and then just created a listitem with the same values – after deleting the rule.

    But yes – not “REALLY” supported by CSOM – from what I can see.

    Let me know how you go !


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s