SharePoint - Updating "Person or Group" field with an SPGroup

1k Views Asked by At

As the title states, such a simple goal, yet nothing i try works and I can't find anything on the web.

SPUser user = ...
item["User"] = user;

SPGroup grp = ...
item["User"] = grp;

Assigning an SPUser works, assigning an SPGroup fails, "Invalid data has been used to update the list item." The field is Person or Group and there are groups already in there.

1

There are 1 best solutions below

0
On

Of course I spend 30 minutes searching the internet before posting on here, then in the next 30 seconds after posting I find the answer.

To those who may be getting the error "Invalid data has been used to update the list item. The field you are trying to update may be read only." it apparently means you provided a string for a lookup type field.

My fault for forgetting I had a lookup field, Microsoft's fault for not making more helpful error messages.