Good time. I want changehave the necessity to switch from using a default field to myusing a custom one in somea number of listslist. I try programmablehave also to "copy" the value contained in the old to-be-deleted column to the new created one. To achieve my goal I have tried a programmatic approach: add my custom field to the list and setthen copy the value from another, arlyer createdalready created field. I washad wrote thatthis code:
SPField newField=list.Fields.CreateNewField("ExtendedPioplePicker", field.Title + "_new");
list.Fields.Add(newField);
foreach (SPItem item in list.Items)
{
var fld = item.Fields.GetField(field.Title + "_new");
fld.Type = Microsoft.SharePoint.SPFieldType.User;
var value=item[field.InternalName];
item[fld.InternalName]=value;
}
But
SPField newField=list.Fields.CreateNewField("ExtendedPioplePicker", field.Title + "_new");
list.Fields.Add(newField);
foreach (SPItem item in list.Items)
{
var fld = item.Fields.GetField(field.Title + "_new");
fld.Type = Microsoft.SharePoint.SPFieldType.User;
var value=item[field.InternalName];
item[fld.InternalName]=value;
}
But then fld.InternalName returnthrows an ArgumentException. What iI need to do for fix problem and update data in field?
Thanks.