private void ChangeContentTypeOrder(ClientContext ctx, List list, string contentTypeName)
{
Microsoft.SharePoint.Client.ContentTypeCollection currentCTOrder = list.ContentTypes;
ctx.Load(currentCTOrder);
ctx.ExecuteQuery();
IList<Microsoft.SharePoint.Client.ContentTypeId> reverceOrder = new List<Microsoft.SharePoint.Client.ContentTypeId>();
foreach (Microsoft.SharePoint.Client.ContentType ct in currentCTOrder)
{
if (ct.Name.Equals(contentTypeName))
{
reverceOrder.Add(ct.Id);
}
}
list.RootFolder.UniqueContentTypeOrder = reverceOrder;
list.RootFolder.Update();
list.Update();
ctx.ExecuteQuery();
}
{
Microsoft.SharePoint.Client.ContentTypeCollection currentCTOrder = list.ContentTypes;
ctx.Load(currentCTOrder);
ctx.ExecuteQuery();
IList<Microsoft.SharePoint.Client.ContentTypeId> reverceOrder = new List<Microsoft.SharePoint.Client.ContentTypeId>();
foreach (Microsoft.SharePoint.Client.ContentType ct in currentCTOrder)
{
if (ct.Name.Equals(contentTypeName))
{
reverceOrder.Add(ct.Id);
}
}
list.RootFolder.UniqueContentTypeOrder = reverceOrder;
list.RootFolder.Update();
list.Update();
ctx.ExecuteQuery();
}
No comments:
Post a Comment