I have an existing list with a text field and records in it. Now I want to change that text field into a calculated field to make it concat two other text fields in the list (possibly by changing the schema related to that field thru code behind). I've tried doing..

fieldThree.Type = SPFieldType.Calculated;
SPFieldCalculated calcField = (SPFieldCalculated)fieldThree;
calcField.Formula = @"=CONCATENATE([fieldOne],"" "",[fieldTwo])";

As it seems.. I can't explicitly convert a text field to a calculated one.

  • @Cimares answer is correct. One side note: To update field definition you need to use fieldThree.Update() instead of myList.Update. In this case it will throw Non-supported field type change exception. – Vedran Rasol May 25 '12 at 11:43

As you've found, you can't convert a text field into a calculated one. What you'll have to do is add the calculated field as a new column.

If you want to do this through code you'll need to use the SPList.Fields.Add() method.

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.