public async Task <IField> AddChoiceMultiAsync(string title, FieldChoiceMultiOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } return(await AddFieldAsync(FieldChoiceMultiOptionsToCreation(title, options)).ConfigureAwait(false)); }
private static FieldCreationOptions FieldChoiceMultiOptionsToCreation(string title, FieldChoiceMultiOptions options) { FieldCreationOptions creationOptions = new FieldCreationOptions(FieldType.MultiChoice); creationOptions.ImportFromCommonFieldOptions(title, options); if (options.FillInChoice.HasValue) { creationOptions.SetAttribute("FillInChoice", options.FillInChoice.Value.ToString().ToUpper()); } StringBuilder sb = new StringBuilder(); if (!string.IsNullOrEmpty(options.DefaultChoice)) { sb.AppendLine($"<Default>{CsomHelper.XmlString(options.DefaultChoice)}</Default>"); } sb.AppendLine("<CHOICES>"); foreach (var choice in options.Choices) { sb.AppendLine($"<CHOICE>{CsomHelper.XmlString(choice)}</CHOICE>"); } sb.AppendLine("</CHOICES>"); creationOptions.SetChildXmlNode("ChoiceXml", sb.ToString()); return(creationOptions); }
public IField AddChoiceMulti(string title, FieldChoiceMultiOptions options) { return(AddChoiceMultiAsync(title, options).GetAwaiter().GetResult()); }
public IField AddChoiceMultiBatch(Batch batch, string title, FieldChoiceMultiOptions options) { return(AddChoiceMultiBatchAsync(batch, title, options).GetAwaiter().GetResult()); }
public async Task <IField> AddChoiceMultiBatchAsync(string title, FieldChoiceMultiOptions options) { return(await AddChoiceMultiBatchAsync(PnPContext.CurrentBatch, title, options).ConfigureAwait(false)); }