/ Get people picker value
var assigned = $().SPServices.SPFindPeoplePicker({
peoplePickerDisplayName: "Assigned To",
checkNames: true
});
OR
//Set Logged User in given people picker field ID
function setPeoplePickerLoginName(id)
{
var PickerDiv = $('[id$="ClientPeoplePicker"][id^="' + id + '"]');
var PickerEditor = PickerDiv.find('[title="' + id + '"]');
var PickerInstance = SPClientPeoplePicker.SPClientPeoplePickerDict[PickerDiv[0].id];
//You need to user SPServices library to get logged user.
var vUserName =$().SPServices.SPGetCurrentUser({fieldName: "Title",debug: false});
PickerEditor.val(vUserName);
PickerInstance.AddUnresolvedUserFromEditor(true);//V.Important line
}
//Return login name of given people picker.
function getPeoplePickerLoginName(id)
{ var PickerDiv = $('[id$="ClientPeoplePicker"][id^="' + id + '"]');
var PickerInstance = SPClientPeoplePicker.SPClientPeoplePickerDict[PickerDiv[0].id];
if(PickerInstance)
{ return PickerInstance.GetAllUserInfo()[0].Key;// i:0#.w|domain\userName
}
else {return "";}
}
No comments:
Post a Comment