Tuesday, March 4, 2014

Get Current User Name using Jquery Onload in sharepoint

1.Down load two files from Jquery
a.jquery-1.8.2.min.js
b.jquery-.SPService-0.7.2.min.js
2.Write the following code after the following place holder in new.aspx of sharepoint list


<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script  src="../../SiteAssets/js/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="../../SiteAssets/js/jquery.SPServices-0.7.2.min.js" type="text/javascript" ></script>
<script type="text/javascript">
$(document).ready(function(){
  var thisUserAccount = $().SPServices.SPGetCurrentUser({ fieldName: "Title", debug: false });
  $("input[title='NotesAuthor']").val(thisUserAccount );
}
);
</script>
 


No comments:

Post a Comment