Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
reworded title to better match question.
Link

Cant update Copy list item field value to newly created custom column

general rewording
Source Link

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.

Good time. I want change default field to my custom in some number of lists. I try programmable add my custom field and set value from another, arlyer created field. I was wrote that 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 fld.InternalName return ArgumentException. What i need to do for fix problem and update data in field?

Thanks.

I have the necessity to switch from using a default field to using a custom one in a number of list. I have 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 then copy the value from another, already created field. I had wrote this 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 then fld.InternalName throws an ArgumentException. What I need to do for fix problem and update data in field?

Source Link

Cant update field value

Good time. I want change default field to my custom in some number of lists. I try programmable add my custom field and set value from another, arlyer created field. I was wrote that 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 fld.InternalName return ArgumentException. What i need to do for fix problem and update data in field?

Thanks.