public async Task <IField> AddCalculatedAsync(string title, FieldCalculatedOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } return(await AddFieldAsync(FieldCalculatedOptionsToCreation(title, options)).ConfigureAwait(false)); }
private static FieldCreationOptions FieldCalculatedOptionsToCreation(string title, FieldCalculatedOptions options) { FieldCreationOptions creationOptions = new FieldCreationOptions(FieldType.Calculated); creationOptions.ImportFromCommonFieldOptions(title, options); creationOptions.SetChildXmlNode("Formula", $"<Formula>{CsomHelper.XmlString(options.Formula)}</Formula>"); if (options.DateFormat.HasValue) { creationOptions.SetAttribute("Format", options.DateFormat.ToString()); } creationOptions.SetAttribute("ResultType", options.OutputType.ToString()); if (options.ShowAsPercentage.HasValue) { creationOptions.SetAttribute("Percentage", options.ShowAsPercentage.ToString().ToUpper()); } return(creationOptions); }
public IField AddCalculated(string title, FieldCalculatedOptions options) { return(AddCalculatedAsync(title, options).GetAwaiter().GetResult()); }
public IField AddCalculatedBatch(Batch batch, string title, FieldCalculatedOptions options) { return(AddCalculatedBatchAsync(batch, title, options).GetAwaiter().GetResult()); }
public async Task <IField> AddCalculatedBatchAsync(string title, FieldCalculatedOptions options) { return(await AddCalculatedBatchAsync(PnPContext.CurrentBatch, title, options).ConfigureAwait(false)); }