2

After referring this article from Marc, and Here am able to get/perform the null check for peoplepicker entries in my custom newform of my SPList within SP Designer 2010.
But, how to retrieve other attributes, like, if i want to get the email id, display name and other details from this ?

I displayed

> alert( innerSpans[0].innerHTML  +  ' is  0th index');    

Message from webpage


 <DIV id=divEntityData style="DISPLAY: none" description="mydomain\p_p" 
    isresolved="True" displaytext="P P" key="i:0#.w|mydomain\p_">
      <DIV data='<ArrayOfDictionaryEntry                 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <DictionaryEntry><Key xsi:type="xsd:string">Email</Key><Value 
         xsi:type="xsd:string">
        P_p@mydomian.com</Value></DictionaryEntry><DictionaryEntry><Key 
       xsi:type="xsd:string">MobilePhone
     </Key>
            <Value xsi:type="xsd:string">+91 98 2726 7723</Value>
        </DictionaryEntry>
         <DictionaryEntry><Key xsi:type="xsd:string">Department</Key>
        <Value xsi:type="xsd:string">mfg</Value></DictionaryEntry>
         <DictionaryEntry><Key xsi:type="xsd:string">
       SIPAddress</Key><Value xsi:type="xsd:string">
        P_p@mydomain.com
      </Value></DictionaryEntry><DictionaryEntry>
      <Key xsi:type="xsd:string">
    Title</Key><Value xsi:type="xsd:string"/></DictionaryEntry>
      </ArrayOfDictionaryEntry>'></DIV></DIV>

and i got above details, but I am stuck with how to extract those
DictionaryEntry from DictionaryEntryArray.

How to iterate through the array of DictionaryEntryArray items.

function getPickerInputElement(identifier) 
{
 alert('  inside getPickerInputElement ');
   alert(identifier);
 var tags = document.getElementsByTagName('DIV');
  for (var i=0; i < tags.length; i++) {
 var tempString = tags[i].id;
 //alert('tags[' + i + '].id = ' + tempString);
  if ((tempString.indexOf(identifier) > 0) && 
   (tempString.indexOf('UserField_upLevelDiv') > 0)){
   //alert('HIT for ' + identifier + ' id=' + tags[i].id + ' value=' + 
   tags[i].value);
 var innerSpans = tags[i].getElementsByTagName("SPAN");
for(var j=0; j < innerSpans.length; j++) {
 //alert('innerSpans[' + j + '].id = ' + innerSpans[j].id);
 if(innerSpans[j].id == 'content') 
 {
  //alert('HIT for ' + identifier + ' id=' + innerSpans[j].id + ' 
   innerHTML=' + innerSpans[j].innerHTML);
  alert( innerSpans[0].innerHTML  +  ' is  0th index');
  return innerSpans[j].innerHTML;
   }    }     }  }
return null; }
 </script>

i tried to get the value below:

 var pp2 = $().SPServices.SPFindPeoplePicker({  peoplePickerDisplayName: 
         whatDisplayName }).row.find("div[id='divEntityData']")
      .attr("displaytext");

so i got the correct value of displayname. But similarly, how to get the other attributes?

2

Your solution with SPServices is just ok. You should use jQuery to parse data and you could use selectors:

var picker = $().SPServices.SPFindPeoplePicker({
   peoplePickerDisplayName: whatDisplayName //your picker control field's display name
});

var data = picker.row.find("div[id='divEntityData'] div").attr("data");

var xml = $(data);//accepting data by jQuery

var data = xml.find('Key:contains("MobilePhone")').next().text();
console.log(data);//data contains mobile phone now 
1
  • Without testing on my end, this looks like the right way to go. – Marc D Anderson Feb 7 '16 at 16:48
0

You can use this below link as a reference and which gives you all attributes belongs to a user:

Get all attributes from user

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.