Add a content editor WebPart to the New form of custom list and add the below code, replace line 18 SetUserFieldValue function parameter to your people picker column name.
I had to change two things to get this code to work for me. I had make sure the people picker javascript library was loaded by calling SP.SOD.executeFunc('clientpeoplepicker.js', 'SPClientPeoplePicker', function () { // rest of code here });
And I had to it appears SharePoint changed the naming convention for the Input field, so I used $("div[title='"+fieldName+"']").find("input"); to retrieve it instead of $("input[title='" + fieldName + "']");
where is the code block???
ReplyDeleteCheck now
DeleteThankz, this code fixed my issue..
DeleteI'm trying to hide the picker field after filling it so the user can't edit it. Any ideas how to extend your code with such function?
ReplyDeletethank
ReplyDeletegreat! It really works for me. Thank you
ReplyDeleteWhere's the code??????
ReplyDeleteIf you are not able view the code in the post, then use this url.
DeleteHi, what can I change if I want to use another user, for example domain\jcartin ?
ReplyDeleteWhat could be the code to add two values on the same field? thank you
ReplyDeleteHello Rajesh, I get correct username(in Alert) after using above script however the peoplepicker does not identify the username. Any hint?
ReplyDeleteThank you, it works perfectly for me
ReplyDeleteWe have updated the sharepoint commulative updates to June, 2016 and now this script is not working, regards,
ReplyDeleteI had to change two things to get this code to work for me. I had make sure the people picker javascript library was loaded by calling
ReplyDeleteSP.SOD.executeFunc('clientpeoplepicker.js', 'SPClientPeoplePicker', function () { // rest of code here });
And I had to it appears SharePoint changed the naming convention for the Input field, so I used $("div[title='"+fieldName+"']").find("input"); to retrieve it instead of $("input[title='" + fieldName + "']");
Excellent. Works as expected.
ReplyDeletei added alert(loginName); before line 18 , i am getting the name of the current user but it desn't set the value to field !!!!!! can you explain why ?
ReplyDelete