I'm trying and failing to set the value of a User column via the SharePoint client model:
int userID;
string displayName;
/*
Look up userID and displayName from Web Service here
*/
Microsoft.SharePoint.Client.File newDocument = documentFiles.Add(creationInformation);
ListItem newItem = newDocument.ListItemAllFields;
item["Selected User"] = String.Format("{0};#{1}", userID, displayName);
item.Update();
Here, we are dealing with a ListItem user column. I was assuming that this behaves in the same way as SPListItem user column: Set with "user ID;#login name". This appears to be correct, although the official documentation doesn't mention this. ("User: When its value is undefined it MUST be CSOM Nothing, otherwise it must be CSOM Object. A lookup to a particular user in the User Info list").
The problem, though, is getting the User ID from the web service. The People service and the Users and Groups service both have fields named ID available, but these IDs don't correspond to the ID you get when looking up the corresponding SPUser object on the server side! In the example above, my user would be "2;#Geir Smestad" on the server side, but "31;#Geir Smestad" on the client side.
How do I find the user ID required to tag a list item?