Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get Content Organizer Rule using CSOM c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
namespace RecordCentreRule
{
class Program
{
static void Main(string[] args)
{
var targetSite = new Uri("https://YourSite.sharepoint.com");
var login = "SomeOne@SharePoint.onmicrosoft.com";
var password = "YourPassword";
var securePassword = new SecureString();
foreach (char c in password)
{
securePassword.AppendChar(c);
}
var onlineCredentials = new SharePointOnlineCredentials(login, securePassword);
using (ClientContext clientCtx = new ClientContext(targetSite))
{
clientCtx.Credentials = onlineCredentials;
Web web = clientCtx.Web;
List routingRulesList = web.Lists.GetByTitle("Content Organizer Rules");
ListItem itm = routingRulesList.GetItemById(1);
clientCtx.Load(web);
clientCtx.Load(routingRulesList);
clientCtx.Load(itm);
clientCtx.ExecuteQuery();
Console.WriteLine("Title: " + itm["Title"] + "\n");
Console.WriteLine("RoutingConditions: " + itm["RoutingConditions"] + "\n");
Console.WriteLine("RoutingConditionProperties: " + itm["RoutingConditionProperties"] + "\n");
Console.WriteLine("RoutingContentType: " + itm["RoutingContentType"] + "\n");
Console.WriteLine("RoutingContentTypeInternal: " + itm["RoutingContentTypeInternal"] + "\n");
Console.WriteLine("RoutingConditions: " + itm["RoutingConditions"] + "\n");
Console.WriteLine("RoutingConditionProperties: " + itm["RoutingConditionProperties"] + "\n");
Console.WriteLine("RoutingAliases: " + itm["RoutingAliases"] + "\n");
Console.WriteLine("RoutingTargetLibrary: " + itm["RoutingTargetLibrary"] + "\n");
Console.WriteLine("RoutingTargetFolder: " + itm["RoutingTargetFolder"] + "\n");
Console.WriteLine("RoutingTargetPath: " + itm["RoutingTargetPath"] + "\n");
Console.WriteLine("RoutingAutoFolderProp: " + itm["RoutingAutoFolderProp"] + "\n");
Console.WriteLine("RoutingAutoFolderSettings: " + itm["RoutingAutoFolderSettings"] + "\n");
Console.WriteLine("RoutingCustomRouter: " + itm["RoutingCustomRouter"] + "\n");
Console.WriteLine("RoutingRuleExternal: " + itm["RoutingRuleExternal"] + "\n");
Console.Read();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment