I'm trying to populate a PeoplePicker field, using this code:
function testPeoplePicker(){
var ppDiv=$("div[title='PP Field Name']");
var ppEditor=ppDiv.find("[title='PP Field Name']");
var spPPD=SPClientPeoplePicker.SpClientPeoplePickerDict;
console.log(typeof spPPD === "undefined");
var spPP=spPPD[ppDiv[0].id];
ppEditor.val("Lastname, Firstname");
spPP.AddUnresolvedUserFromEditor(true);
}
SP.SOD.executeFunc("/_layouts/15/clientpeoplepicker.js","SP.ClientContext",function(){
setTimeout(function(){
testPeoplePicker();
},2000);
});
However, the typeof spPPD === "undefined"
check returns true, indicating that the PeoplePicker dictionary is undefined, and the spPPD[ppDiv[0].id]
lookup gives this error:
Unable to get property
'PPFieldName_0e1071d1-0f13-47dd-957f-1cab4c98c3f2_$ClientPeoplePicker'
of undefined or null reference
Any idea why I can't access the People Picker dictionary?