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

Insert to a "People or Group" field from a "people picker"

Feb 21, 2012 at 1:04 PM
Edited Feb 21, 2012 at 1:35 PM


I have a "people picker" control on a page, and I want to grab its value in insert into a column of type "person or group". 

So I have the control:

<SharePoint:PeopleEditor ID="spPeoplePicker" Title="Owner" runat="server" Width="350" SelectionSet="User"/>

And I can grab the NTID no problem, it resolves as DOMAIN\username

_Owner =  $("textarea[title='Owner']").val();

When I try to insert this as part of a value pair - I get an error. It seems that the field is expecting it in the format:




How can I get this numeric ID for the user I am trying to add?  Or has anyone else added someone from a people picker to a person or group field?





Feb 21, 2012 at 1:43 PM

Getting closer....:


Feb 21, 2012 at 1:52 PM


You should be able to use the value as 0;#domain/username. SharePoint will figure out the ID for you. This assumes you're within a single Site Collection.


Feb 21, 2012 at 2:09 PM

Hi Marc, 


Sorry - that doesnt work at all. When I insert "0#;DOMAIN/edwardsm" the value in the field is blank, a closer look with "U2U Caml builder" gives the value as  "0#;"


I also tried:




But none worked. 


This article suggests that the userID is available using the Object model, but that the user must be "ensured" first:

 SPUser user = web.EnsureUser(sAlias); 
  sAllContacts += user.ID.ToString() + ";#" + user.LoginName.ToString() + ";#"; 


Would this EnsureAlias be available via spservices?

Im using moss 2007 if that makes a difference.





Feb 21, 2012 at 3:01 PM

I'm assuming you are generating an AJAX update via SPServices... Because a USER/GROUP field is a "lookup" field, try using only the ID integer on the update and set the... Here is an example:

<Method ID='1' Cmd='New'>
    <Field Name='User' LookupId='True'>1</Field>


Like Marc stated: sharepoint should take care of populating the name of the user... I have done this for People... don't recall if I ever did it for Group's... should work the same.

Also, take a look a this post which also describes how you can grab information about selected users (in the people picker) on the page:

Good luck.



Feb 21, 2012 at 4:32 PM

Thanks for the reply, 

I dont understand - the problem is that I dont know the ID Integer of the user. I am using a people picker - from which I can get the NTID (edwardsm) - but I cant get the NTID.

Using "GetUserInfo" service works to get the numeric ID - but only if they are already a sharepoint user. If that person is not already a sharepoint user, then there isnt an ID yet. (If you use the standard new item form - the people picker seems to handle this).


Thats why the link above suggests using "ensureuser" - but thats using server side code - I cant work out how to access this via web services. 







Feb 21, 2012 at 4:54 PM


What I was trying to describe, is that once a user, through the People Picker field, selects a users, SP actually stores information about the selected user in a hidden <div> element on the page until the form is ready to be "saved/submitted"... You can use Javascript to find that hidden element and drill down to get the ID of that selected user. 

The prior link I posted shows you how to get the NTID of a user that was selected/resolved by the people picker (note... its important to not just get whatever value in on "$("textarea[title='Owner']").val()" as you are doing above... a user could have just typed in some junk text and never relay picked a valid and "resolved" user)

Using the method to find the resolved entries by the people picker and IE's Debugger, you can walk through the DOM tree to see the HTML structure and then use jQuery to get the user's ID.


Feb 21, 2012 at 5:23 PM

Yes - thanks, 

But - it only works if the user has visited the sharepoint site. Even if the People Picker resolved the user (as they are a valid active directory user) seems that Sharepoint does not create a user profile unless they login to that site collection.

I think that is what the ensueuser method does - but is there anyway to do this with spservices?:











Feb 21, 2012 at 6:21 PM


Just so that we keep each item in sync... your initial issue of, Unable to get the ID for a resolved USER via a People Picker field, is not fixed, Correct? You are able to get the ID?

Or are you saying that if the user is not "...login to that site collection", the People Picker does not resolve the selected USER?

Can you paste the JavaScript code that is attempting to use the ID of the resolved user.

The question around EnsureUser operation would need the help of Marc.


Feb 21, 2012 at 7:08 PM

Thanks for your help - but I think its the same issue. 

Your solution works - but only if the user has at some point logged into the site collection.  If the user has not logged into the sharepoint site - then the people picker does not produce an ID - and you cant use "GetUserInfo" either.

That's what this ensureuser seems to do... create a new SPID if it doesnt exist...but I dont know if this is feasible using spservices.





Feb 21, 2012 at 7:22 PM


Got it... Thanks for the post back...

I'm sure Marc will try to respond when he gets a chance.


Apr 13, 2015 at 10:12 AM

sorry about write into this old post, but finally you got the solution for this issue?

Apr 29, 2015 at 10:16 PM
It's best not to add onto such an old thread. If you're having a problem, please start a new thread with your details.