2

I am trying to create calculated column using csom.

var fieldXml="<Field Name='calctest' DisplayName='calctest' StaticName='calctest' Type='Calculated' Required='FALSE' ColName='sql_variant1' Format='DateOnly' EnforceUniqueValues='FALSE' Description='weg' Indexed='FALSE' ResultType='DateTime' ReadOnly='TRUE' LCID='1033' Version='2' ><Formula>=DATE(YEAR(Approval_x0020_Date)+3,MONTH(Approval_x0020_Date)+1,DAY(Approval_x0020_Date)+5)</Formula><FormulaDisplayNames>=DATE(YEAR([Approval Date])+3,MONTH([Approval Date])+1,DAY([Approval Date])+5)</FormulaDisplayNames><FieldRefs><FieldRef Name="Approval_x0020_Date" /></FieldRefs></Field>";
olist.Fields.AddFieldAsXml(fieldXml, true, AddFieldOptions.AddToDefaultContentType);
fieldTxt.Update();
olist.Update();
clientcontext.ExecuteQuery();

After executing i am getting Error:

The formula refers to a column that does not exist. Check the formula for spelling mistakes or change the non-existing column to an existing column.

when i am running same code just changing column in formula, it runs smoothly and creates calculated column perfectly.

i.e If i Use Column name=Approval Date (Static name="Approval_x0020_Date"), it will throw above error.

If I use Column name=ApprovalDate (Static name="ApprovalDate"), it will work fine.

Does anyone know why it is not accepting 2 or more than 2 words of column name.

Thanks in advance.

1

Finally i got solution.

I replaced [Approval_x0020_Date] with [Approval Date]. i.e with display name.

Thanks Submits

  • Strange! In my case I have to use the internal name, after having tried display name. We love SharePoint. – Submits May 27 '16 at 15:09
0

Try putting the column name in square brackets like [Approval_x0020_Date].

The name should be the internal name of the column.

  • Tried. not working, it gives same error – Anil Pal May 27 '16 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.