none
How to set People picker data form list to people picker control have div using Jquery in sp 2013? RRS feed

  • Question

  • I have .html page with custom code in .aspx page. In that i have some cusom code with jquery.

    I have a people picker control which handled with div conrol. Please refer the below code.

    <label >Approver 1</label><label> <div class="inner-wrap peoplePick"  id="peoplePickerAppr1"></div></label>

    i am able to save people picker daat to list column.But while fetching the data in edit mode i am getting the data.bur not able to set to above control.

    My code:

    Under document.ready function :

    initializePeoplePicker('peoplePickerDivAppr1');

             

    var clientContext = new SP.ClientContext(); 
    var targetList = clientContext.get_web().get_lists().getByTitle('DocumentApproval');
    targetListItem = targetList.getItemById(itemId);
    clientContext.load(targetListItem);
    clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);
    }
            }
    function onQuerySucceeded() {  

       

    if(targetListItem.get_item('Approver_x0020_1')){  $("#peoplePickerDivAppr1_TopSpan").html(targetListItem.get_item('Approver_x0020_1').get_lookupValue());

    } //showing only for this cotrol.

    In edit mode if i am not able to edit this people picker field data.Because i am adding the data to div control.

    SP please provide the solution to modify after set the the data to people picker control.

    SPfindpeoplepicker is not working in my case.

    Please help.Provide the code for able to update in edit form in Jquery.

    Wednesday, February 8, 2017 4:47 PM

Answers

  • Hi sudhir,

    Here is a code demo about setting people picker control using Jquery:

    function SetUserFieldValue(fieldName, userName) {
     var _PeoplePicker = $("div[title='" + fieldName + "']");
     var _PeoplePickerTopId = _PeoplePicker.attr('id');
     var _PeoplePickerEditer = $("input[title='" + fieldName + "']");
     _PeoplePickerEditer.val(userName);
     var _PeoplePickerOject = SPClientPeoplePicker.SPClientPeoplePickerDict[_PeoplePickerTopId];
     _PeoplePickerOject.AddUnresolvedUserFromEditor(true);
    }

    More information:

    SharePoint 2013: Pre-Populate People Picker value to Current user

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by sudhir muvva Friday, February 10, 2017 8:05 AM
    Thursday, February 9, 2017 8:30 AM

All replies

  • Hi sudhir,

    Here is a code demo about setting people picker control using Jquery:

    function SetUserFieldValue(fieldName, userName) {
     var _PeoplePicker = $("div[title='" + fieldName + "']");
     var _PeoplePickerTopId = _PeoplePicker.attr('id');
     var _PeoplePickerEditer = $("input[title='" + fieldName + "']");
     _PeoplePickerEditer.val(userName);
     var _PeoplePickerOject = SPClientPeoplePicker.SPClientPeoplePickerDict[_PeoplePickerTopId];
     _PeoplePickerOject.AddUnresolvedUserFromEditor(true);
    }

    More information:

    SharePoint 2013: Pre-Populate People Picker value to Current user

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by sudhir muvva Friday, February 10, 2017 8:05 AM
    Thursday, February 9, 2017 8:30 AM
  • Hi ,

    Thanks.This is working.

    Friday, February 10, 2017 8:06 AM