Update Content Type

 

var ctypes = listTeam.ContentTypes;
context.Load(ctypes, ctys => ctys.Include(c => c.FieldLinks, c => c.Id, c => c.Name));
context.ExecuteQuery();
string GUID = "";
foreach (var item in ctypes)
{
    if (item.Name == "Item"){
        GUID = item.Id.ToString();
break;
}
}
var contentType = ctypes.GetById(GUID); context.Load(contentType, ct => ct.FieldLinks); context.ExecuteQuery(); var fields = contentType.FieldLinks; foreach (var fld in fields) { if (fld.Name != "Title" && fld.Name != "DocType" && fld.Name != "Categories") { fld.Hidden = true; } } contentType.FieldLinks.Reorder(new string[] {"Categories", "Comments", "Created", "DocType","Modified","Reviewer", "Title" }); contentType.Update(false); context.ExecuteQuery();

 

posted @ 2018-06-21 13:55  JackHu88  阅读(96)  评论(0编辑  收藏  举报