Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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;
myList.Update();
SPFieldCalculated calcField = (SPFieldCalculated)fieldThree;
calcField.Formula = @"=CONCATENATE([fieldOne],"" "",[fieldTwo])";
calcField.Update();

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

share|improve this question
    
@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

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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