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 !