I am trying to create Calculated Column in SharePoint Document Library using Client Object Model.
However getting following error while executing FieldSchema:
Name cannot begin with the '\"' character, hexadecimal value 0x22
Code:
var calculated = "Calculated";
var displayName = "Effective Date";
var internalName = "Effective Date";
var formula = "=IF(ISBLANK(Col_DocumentEffectiveDate),\"\",TEXT(Col_DocumentEffectiveDate,\"DD-Mmm-YYYY\"))";
List lib = clientContext.Web.Lists.GetByTitle(docLibName);
clientContext.Load(lib);
clientContext.ExecuteQuery();
string fieldSchema = "<Field Type=\"" + calculated + "\" DisplayName=\"" + displayName + "\" Name=\"" +internalName+ "\" Formula=\"" + formula + "\"
/>";
lib.Fields.AddFieldAsXml(fieldSchema, true, AddFieldOptions.AddFieldInternalNameHint);
clientContext.ExecuteQuery();
Code does't work if i replace quotation marks("\) in Formula with """
Could someone help with issue?