Google+

Invalid data has been used to update the list item

1

August 16, 2012 by Ruaan Harmzen

I thought over the next couple of weeks I can share some development\coding topics on Sharepoint 2010. Starting with:

“Invalid data has been used to update the list item. The field you are trying to update may be read only”

This error is usually occurs when updating or creating a new list item that contains a person\group field. As per normal with Sharepoint 2010 (and Microsoft for that matter) the error description has nothing to do with the actual problem (anyone remember “~ of ~ failed”).

The error is caused because of the method we use to update the person field, in my case it was:

Item[“Assignee”] = Environment.Username;

The correct way to do this and any use of the SPUser class would be:

SPUser user = web.EnsureUser(Environment.Username);

Item[“Assignee”] = user;

 

The EnsureUser method does some internal “magic” and make person field updates a lot less prone to error.

Advertisements

One thought on “Invalid data has been used to update the list item

  1. ysssm says:

    Super post.. really help ful..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: