This project has moved and is read-only. For the latest updates, please go here.

Set the value of a 'person or group' column (2010)

Apr 12, 2011 at 11:54 AM
Edited Apr 12, 2011 at 11:57 AM


How would you set the value of a "person or group" colum?

I have tried to use SPGetcurrentUser and UpdateListItems - but I get a "one or more fields have not been installed correctly.

I think this is because the contents of a "person or group" seems to be a pair of a numeric ID and the title. eg.:

          23;#Edwards, Mike

What is this number? And can I get it for the current user and concatinate itogether, and use the string?

Can anyone help? Here is my code:

 var thisUserName = $().SPServices.SPGetCurrentUser({
	fieldName: "Title",
	debug: false

function addMeToCourse(theid){
      	       operation: "UpdateListItems",
       	       async: false,
listName: "Training Attendees Table",
valuepairs: [["ows_users", thisUserName]], completefunc: function (xData, Status) { alert(Status); alert(xData.responseXML.xml);
} }); }
Many thanks
*Edit - I had missed out the "ID:theid" parameter - this wasnt the problem tho :(


Apr 12, 2011 at 12:49 PM

I believe your issue is with the Valuepairs.  "ows_users" should probably just be "users".

Try that and see what happens.

Apr 12, 2011 at 12:53 PM

Yes - that works....

Thanks you, thank you, thank you, thank you, thank you, thank you.



Apr 12, 2011 at 12:57 PM
Edited Apr 12, 2011 at 12:57 PM

Yes, assuming that the StaticName (internal name) of the column is "users".

You do also need the ID of the user for the update to work.

BTW, there's no debug mode for the core Web Services calls in $().SPServices.


Apr 12, 2011 at 1:18 PM

Thanks for the input.


By "the ID of the user" do you mean the numeric value that makes up the hash pair?

I am having some success using "-1#" plus the fieldName "Name" returned from SPGetCurrentUser.

In this code - "fullAttendees" is a string containing the contents of the same field, but before I update it (so a string of 'id#username;')

var thisUserName = $().SPServices.SPGetCurrentUser({
         fieldName: "Name",
         debug: true

updateText =fullAttendees+";#-1;#"+thisUserName;
             operation: "UpdateListItems",
              async: false,
              listName: "Training Attendees Table",
              valuepairs: [["users", updateText ]],
              completefunc: function (xData, Status) {

This *seems* to be working. Thanks for your help.

Apr 12, 2011 at 1:23 PM
Edited Apr 12, 2011 at 1:24 PM

I'm not sure about the -1 thing. If the column value is being updated correctly, then that's an interesting trick. Even if that works, where you'll run into problems is if any two or more people have the same name.

The number 23 in "23;#Edwards, Mike" is the ID of the user named Mike Edwards in the User Information List. This notation is used across SharePoint to specify ID;#value pairs. IMO the primary reasons for this "double" storage is for compatibility with Office desktop apps as well as to improve efficiency on rendering individual items. (Believe you me, it can cause issues, as well.)


Apr 12, 2011 at 1:28 PM

Thanks -

Yeah I found an article somewhere advocating its use - this was using C# - not the web services. But it seems to work.

So how can I get the ID of the current user? The SPGetCurrentUser documentation doesn't appear to contain a reference to an 'ID' fieldname...


Apr 12, 2011 at 1:49 PM

No, SPGetCurrentUser doesn't have an ID option, but I just took a look and you can grab it from the variable _spUserId, which SharePoint sets.



I should add ID as an option to SPGetCurrentUser.


Apr 12, 2011 at 1:52 PM

Thats great - thank you very much for your help.

And thanks for your great framework!


Apr 12, 2011 at 1:55 PM

Hmmm... All this time I've been doing a double call.  SPGetCurrentUser/GetUserInfo.

Thanks for the tips...

Apr 12, 2011 at 2:11 PM

BTW, I just validated that _spUserId is present in both 2007 and 2010.


Apr 12, 2011 at 2:17 PM

Logged and added to v0.6.1ALPHA3.