The solution - We had to interfere in our lists, and touch those "read only" columns \ Fields. Remembering we had to avoid changing those lists\Doclibs columns and keep the "old" metadata ( before the retrieval process ).
Code Snippet for how changing the data in the "read only" column such as "Modified" -
SPFieldCollection colFields = list.Fields;
for (int i = 0; i < colFields.Count; i++)
{
SPField field = colFields[i];
try
{
if (list.Fields[i].Title == "Modified")
{
if (field.ReadOnlyField)
{
list.Fields[i].ReadOnlyField = false;
for (int j = 0; j < list.Items.Count; j++)
{
SPListItem oListItem = list.Items[j];
DateTime date = (DateTime)oListItem[list.Fields[i].Title];
// updating the relvant stuff on that item.
oListItem[list.Fields[i].Title] = date;
oListItem.Update();
}
}
}
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
You can play with it more, and adjust it. Hope you got the idea.
Good luck.
No comments:
Post a Comment