In this post we will discuss how to Auto populate current logged in user name in SharePoint 2010 People Picker control. Here we will do by using SPServices js file provided by Codeplex. We will not use any server side code.
Also check out:
Here my requirement is I have a SharePoint list that has a people picker control in it. I want to show the logged in user name or email id there when ever user try to add an item to the list. So here we will put the code js code in the Default New Form. For this Open the List -> Customize List -> then Form Web Parts -> then click on Default New Form as shown in the fig below:
This will open the Default New Form in Edit mode. Here you click on Add a Web Part and then add a Content Editor Web Part. Once the web part added, go to format text and then Markup and then Edit Source as shown in the fig below.
In the source editor put the below code:
var userName= $().SPServices.SPGetCurrentUser();
This will work in SharePoint 2010. I tried in SharePoint 2013 but it did not work, If any one have solution for SharePoint 2013, Please let me know.