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();

猜你喜欢

转载自www.cnblogs.com/jackhu88/p/9208674.html
今日推荐