Hi all, I am trying to update data in the sharepoint list but when I tried to update data in the sharepoint list by calling update() method I got following excaption:
Invalid data has been used to update the list item. The field you are trying to update may be read only.
please tell me how to get done with solving this problem?
thanks
Loading
Bijayani BaijayantiPosted Jun 22, 2010, 7:37 AM
SPListItem item = SPList.Items.Add();
item["Column1"] = "value for column 1";
item["Column2"] = "value for column 2";
item.Update();
The last line in the code above "item.Update()" does the final task of updating all the assigned value for that specific item within the SPList.
But is this the only way to update an item? No, we can also update the same item using
item.SystemUpdate();
Hope you find this tips useful and of assistance.
Thanks,
Bijayani
Learn about SharePoint Migration.
Lalit MPosted Apr 21, 2010, 12:59 AM
This error is encountered because when trying to modify the above mentioned fields and use the listitem.Updated() property to implement the changes.
The ListItem.Update() method will affect changes to the modified or the modified by fields, thus to overcome this issue it is always advisable to use the ListItem.SystemUpdate() property to implement the changes. Basically the SystemUpdate property updateds the chages made to the list item without affecting changes to the Modified or the Modified By fields.
For more information on SystemUpdate,
http://msdn.microsoft.com/en-us/library/ms461526.aspx
http://sanketinfo.wordpress.com/2009/07/26/error-invalid-data-has-been-used-to-update-the-list-item-the-field-you-are-trying-to-update-may-be-read-only/
http://blogs.technet.com/victorbutuza/archive/2009/01/20/sharepoint-designer-2007-workflow-error-occurred-on-update-list-item-when-field-is-person-group.aspx