Sunday, October 9, 2016

Get Login UserName fon Preload of SharePoint List "NewForm.aspx"

Step 1:  Downlaod SPServices.js latest files

Step 2: Place the J.s filed into Asset Libraries

Step 3 :Replace the url of the SP.Services to your Side from below yellow color highlighted url

Step 4: Change the first parameter Name which should be the column from "Title" to  your  list column name in the function
SetUserFieldValue("Title",loginName);

<script src="https://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js" type="text/javascript"></script>

<script src="/SiteAssets/jquery.SPServices-2014.02.js" type="text/javascript"></script>


<script type="text/javascript">

$(document).ready(function () {

 var loginName= $().SPServices.SPGetCurrentUser();

SetUserFieldValue("Title",loginName);



function SetUserFieldValue(fieldName, userName) {

 var _PeoplePicker = $("div[title='" + fieldName + "']");

 var _PeoplePickerTopId = _PeoplePicker.attr('id');

 var _PeoplePickerEditer = $("input[title='" + fieldName + "']");

 _PeoplePickerEditer.val(userName);

 var _PeoplePickerOject = SPClientPeoplePicker.SPClientPeoplePickerDict[_PeoplePickerTopId];

 _PeoplePickerOject.AddUnresolvedUserFromEditor(true);

}

});
</script>

1 comment:

  1. A nice article here, i think that people who have grown up with the idea of using computers are showing more responsibility towards writing posts that are thoughtful, and pertinent to the post..

    Sharepoint Training in Chennai

    ReplyDelete