protected override void ExecuteCmdlet() { Field field = Field.Field; if (field == null) { if (Field.Id != Guid.Empty) { field = CurrentWeb.Fields.GetById(Field.Id); } else if (!string.IsNullOrEmpty(Field.Name)) { field = CurrentWeb.Fields.GetByInternalNameOrTitle(Field.Name); } ClientContext.Load(field); ClientContext.ExecuteQueryRetry(); } if (field == null) { throw new PSArgumentException("Field not found", nameof(Field)); } var ct = ContentType.GetContentTypeOrWarn(this, CurrentWeb); if (ct != null) { CurrentWeb.AddFieldToContentType(ct, field, Required, Hidden, true, true, false); } }
protected override void ExecuteCmdlet() { List list = List.GetList(CurrentWeb); var ct = ContentType?.GetContentTypeOrWarn(this, CurrentWeb); if (ct != null) { CurrentWeb.AddContentTypeToList(list.Title, ct, DefaultContentType); } }
protected override void ExecuteCmdlet() { var list = List.GetListOrThrow(nameof(List), CurrentWeb); var ct = ContentType.GetContentTypeOrWarn(this, list); if (ct != null) { CurrentWeb.RemoveContentTypeFromList(list, ct); } }