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>

4 comments:

  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
  2. Wow amazing i saw the article with execution models you had posted. It was such informative. Really its a wonderful article. Thank you for sharing and please keep update like this type of article because i want to learn more relevant to this topic.see page School website design uk

    ReplyDelete
  3. Excellent .. Amazing .. I will bookmark your blog and take the feeds additionally? I’m satisfied to find so many helpful information here within the put up, we want work out extra strategies in this regard, thanks for sharing..

    Back to Original Services Private Limited

    ReplyDelete
  4. Thank you for this great article which conveyed a good information.keep more updates.
    SEO Company in India

    ReplyDelete