I am using SharePoint 2007. I have a custom aspx page in the layouts folder containing a people picker (PeopleEditor
) control.
Users can enter n
nunmber of users in the control. I want to retrevie the users' emails from the people picker control using javascript, can someone please help.
General
People fields are pretty complicated, but I'll do my best to explain what I've found out from doing some work with them while updating my library (SPUtility.js). You can take a look at the
SPUserField
class in the library to see. I mostly used Firebug + Firefox to reverse engineer the field. Unfortunately, the field is generated differently depending on what browser is used.textarea
is displayed.First, a list of the controls that make up the field:
There actually are a couple more controls, but I haven't found them to be useful (HiddenEntityKey, HiddenEntityDisplayText).
Getting the controls
I'm not sure how the HTML works in an ASPX page but in a regular SharePoint form, there is a
<span class="ms-usereditor">
. All the other controls seem to be contained in this span. This makes it relatively easy to get the other controls:Setting the field
To understand, I'm including the details for setting the field as well.
Getting the field value
After the Check Names button is clicked and the AJAX executes, your controls should then be populated with new information. The upLevelDiv seems to contain most of it but hiddenSpanData also contains some.
After an execution, upLevelDiv (or hiddenSpanData) will probably contain something like this:
Then, all you need to do is parse out the
ArrayOfDictionaryEntry
XML object to read their email.