I created one Custom Column name Employee Name it is Person/Group type, when user open New item current login user name show in this column

How to do this?

2 Answers 2


You can add custom JavaScript in Script editor or Content editor web part on list form page.


<script src="https://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices-2014.02.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        // get the title of current user  
        var currentUserName = $().SPServices.SPGetCurrentUser({
            fieldName: "Title",
            debug: false
        //populate the field "Employee Name" with the current user  
        $('textarea[title^="Employee Name"]').val(currentUserName);
        $('input[title^="Employee Name"]').val(currentUserName);

Reference: Auto Populate Current User Login Name in SharePoint


<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="http://sharepoint.crescent.com/helpdesk/support/jquery.SPServices-2013.01.min.js"></script>

<script type="text/javascript">
    $(document).ready(function () {
        //Get the current user details 
        var user = $().SPServices.SPGetCurrentUser();

        //Find the Specific People picker field "Employee Name" and set its value 
            peoplePickerDisplayName: "Employee Name",
            valueToSet: user,
            checkNames: true

Reference: Set SharePoint People Picker Default Value to Current User

  • hi it will be work in NewForm.aspx ? Commented Jun 22, 2021 at 7:58
  • @ganeshsanap the above code will work only if column type is single line text field or multiline text field Commented Jun 22, 2021 at 8:05
  • For people picker field, try solution given here. let me know if it works for you. Commented Jun 22, 2021 at 8:09
  • 1
    thank it worked for me Commented Jun 22, 2021 at 8:12

you can use below code to set the people/group value with the current logged in user name

$(document).ready(function () {

var userid = _spPageContextInfo.userId;

function GetUserLogin() {
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";

var requestHeaders = { "accept" : "application/json;odata=verbose" };

  url : requestUri,
  contentType : "application/json;odata=verbose",
  headers : requestHeaders,
  success : QuerySuccess,
  error : QueryError

function QuerySuccess(data, request){
  //removes the claims encoding
  var loginName = data.d.LoginName.split('|')[1];

function QueryError(error) {



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.