public override void Create() { if (TargetContentType == null) { throw new Exception("Cần cung cấp content type"); } Field targetField = GetField(); if (targetField == null) { throw new Exception($"Field {InternalName} không tồn tại."); } FieldLinkCreationInformation fldLink = new FieldLinkCreationInformation { Field = targetField }; fldLink.Field.Required = false; fldLink.Field.Hidden = false; TargetContentType.FieldLinks.Add(fldLink); TargetContentType.Update(false); _context.ExecuteQuery(); }
public override void Create() { if (TargetContentType == null) { throw new Exception("Cần cung cấp content type"); } var rootWeb = _context.Site.RootWeb; Field newField = rootWeb.Fields.AddFieldAsXml(XmlSchema, false, AddFieldOptions.AddFieldInternalNameHint); newField.Group = "Training"; TargetContentType.FieldLinks.Add(new FieldLinkCreationInformation { Field = newField, }); TargetContentType.Update(false); _context.ExecuteQuery(); }