enter image description here

How to extract people picker value so that i can use it in code dynamically on Edit Form page.

Try to check this to get people picker value

<script src="/JSLibrary/jquery-1.3.2.min.js" type="text/javascript">
<script type="text/javascript">
$(document).ready(function() {
$("input[title='JM ID']").focus(function()   {
var User = $("textarea[title='People Picker']").val().split("\\");
$("input[title='JM ID']").val(User[1]);
});
});

Ref

  • I am also here if you need more clarification – Mohamed El-Qassas MVP Jul 22 '16 at 13:29
  • what should i write at the place of 'JM ID'... or as it is – Akul Jul 22 '16 at 13:41
  • your control in edit form – Mohamed El-Qassas MVP Jul 22 '16 at 13:43

Here is a snippet that you can use

$('.ms-entity-resolved[id^="txt_MentorName"]').attr('title');

Or

Copied From - https://blog.sprider.org/2012/04/23/get-sharepoint-people-picker-value-using-java-script/

var PickerPerson = getPickerInputElement("ff13"); // Here ff13 is your people picker control ID

function getPickerInputElement(identifier) {
    var tags = document.getElementsByTagName(‘DIV’);
    for (var i=0; i < tags.length; i++) {
        var tempString = tags[i].id;
        if ((tempString.indexOf(identifier) > 0) && (tempString.indexOf(‘UserField_upLevelDiv’) > 0)){
            var innerSpans = tags[i].getElementsByTagName(“SPAN”);
            for(var j=0; j < innerSpans.length; j++) {
                if(innerSpans[j].id == ‘content’) {
                    return innerSpans[j].innerHTML;
                }
            }
        }
    }
    return null;
}
  • It is giving undefined by using this. – Akul Jul 22 '16 at 13:40
  • Did you put the correct field Name? Please use browser tool to find it – Amal Hashim Jul 22 '16 at 13:41
  • $('ms-inputuserfield[id="ctl00$m$g_332d4490_608a_44d1_9ce9_572cdcceba13$ff1_1$ctl00$ctl00$UserField$downlevelTextBox"]').attr('title'); i used this id from F12 for the div containing the people picker, still getting undefined.... should i use different id – Akul Jul 22 '16 at 13:46
  • Can i write this code in sp designer aspx page? – Akul Jul 22 '16 at 13:54
  • Yes you can edit the form in advanced mode.. another option is to edit the page in browser and add a content editor webpart – Amal Hashim Jul 22 '16 at 14:00

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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