Monday, 2 February 2015

Get current logged user details in SharePoint using spservices

Share it Please
 1.Create one Content Editor WebPart and  paste the below code

<script type="text/javascript" src="https://Site Collection Url/sites/TestSite/Style Library/Samples/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="https://Site Collection Url/sites/TestSite/Style Library/Samples/jquery.SPServices-2014.02.min.js"></script>

<script type="text/javascript">

$(document).ready(function() { 

 GetLoggeduserInfo();
   
});

function GetLoggeduserInfo()
{

$().SPServices({
    operation: "GetUserInfo",
    async: false,
    userLoginName: $().SPServices.SPGetCurrentUser(),
    completefunc: function (xData, Status) {
        $(xData.responseXML).find("User").each(function() {
            curUserId = $(this).attr("ID");
            curUserName = $(this).attr("Name");
            curFullUserName = $(this).attr("ID")+";#"+$(this).attr("Name");
            alert(curFullUserName);
        });
    }
});
}

</script>

No comments:

Post a Comment

Followers

Follow The Author