2

I'm trying to get ClientPeoplePicker control with following code.

    function setCPP(userAccountName, controlName) {
    var peoplePickerDiv = $("[id$='ClientPeoplePicker'][title='" + controlName + "']");
    var peoplePickerEditor = peoplePickerDiv.find("[title='" + controlName + "']");
    var spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];
    peoplePickerEditor.val(userAccountName);
    spPeoplePicker.AddUnresolvedUserFromEditor(true);
}

I can get peoplePickerEditor and peoplePickerDiv[0].id without problem, but spPeoplePicker is undefined. What did I miss?

1

Resolved issue by adding timeout. Before that the function works in IE11, with timeout added also works in IE10.

 ExecuteOrDelayUntilScriptLoaded(function () {
        setTimeout(function () {
            setCPP(userAccountName, controlName);
        }, 2000);
    }, 'clientpeoplepicker.js');

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.