Thursday, 12 February 2015

SharePoint 2013: How to get current user name using spservices.js

How to get current user name using spservices.js:

Then download the SPUtility.js file from http://spservices.codeplex.com/ and jquery-1.11.2.min.js file as well.

<script type="text/javascript" src="/Style Library/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="/Style Library/spservices.js"></script>

$(document).ready(function() {      
        var currentAbsoluteUrl = window.location.protocol + "//" + window.location.host;
        var currentUserName= $().SPServices.SPGetCurrentUser({
        webURL:currentAbsoluteUrl,
        fieldName: "Title",
        debug: false
    });
  alert('User Name:'+currentUserName);
});

1 comment:

  1. The other day, while I was at work, my cousin stole my iphone and tested to see if it can survive a twenty five foot drop, just so she can be a youtube sensation. My apple ipad is now broken and she has 83 views. I know this is completely off topic but I had to share it with someone!

    ReplyDelete