0

I just noticed a javascript function that finds and populates people picker controls in SharePoint was not working in Edge, whereas it works fine in Chrome and IE.

In Edge I see an error in the console log related to the code below: 'SPClientPeoplePicker' is not defined

    var controlName = "External";
    var ppDiv = $("[id$='ClientPeoplePicker'][title='" + controlName + "']");
    var ppEditor = ppDiv.find("[title='" + controlName + "']");
    var spPP = SPClientPeoplePicker.SPClientPeoplePickerDict[ppDiv[0].id];

    ppEditor.val(cuser);
    spPP.AddUnresolvedUserFromEditor(true);

Has anyone else come across this? If so, any solutions?

  • Is there any updates ? – Jerry_MSFT Sep 4 '19 at 9:27
0

Add a reference to clientpeoplepicker.js will fix this error in Edge Browser:

<script type="text/javascript" src="/_layouts/15/clientpeoplepicker.js"></script> 
<script type="text/javascript">
 window.setTimeout(function() {
      SetAndResolvePeoplePicker("Account Manager", _spPageContextInfo.userLoginName);
      }, 750);



function SetAndResolvePeoplePicker(fieldName,Name) 
{

        var controlName = fieldName;
        var peoplePickerDiv = $("[id$='ClientPeoplePicker'][title='" + controlName + "']");
        var peoplePickerEditor = peoplePickerDiv.find("[title='" + controlName + "']");
        var spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];
        peoplePickerEditor.val(Name);
        spPeoplePicker.AddUnresolvedUserFromEditor(true);  
}
</script>
| improve this answer | |

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.