Thursday 1 February 2018

Autofill people picker in sharepoint

function setLoginName() {
debugger;
    var loginName = _spPageContextInfo.userLoginName;
    var peoplePickerDiv = $("[id$='ClientPeoplePicker'][title='Name']");
    var peoplePickerEditor = peoplePickerDiv.find("[title='Name']");
    var spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];
    peoplePickerEditor.val(loginName);
    spPeoplePicker.AddUnresolvedUserFromEditor(true);
}
$(document).ready(function(){
SP.SOD.executeFunc('clientpeoplepicker.js', 'SPClientPeoplePicker', function () {
       setLoginName(); //your code goes here
    });
});


No comments:

Post a Comment

Featured post

Data connections in Infopath forms

https://www.qdoscc.com/blog/how-automatically-retrieve-current-username-infopath-sharepoint-list-form

Popular Posts