.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Get the manager of the current SharePoint user Using SPServices and GetUserProfileByName

Posted By:Sagar Pardeshi       Posted Date: January 06, 2014    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

Get the manager of the current SharePoint user Using SPServices and GetUserProfileByName

Introduction :

We  get the current user's manager and put the value into a Person or Group column in a list. This one only works in SharePoint Server 2010 & SharePoint Foundation .because the UserProfileService Web Service is only available there.

The code is relatively straightforward: a call to SPServices to get the results from  GetUserProfileByName and then a little more code to poke it into the appropriate Person or Group column. In this case, the Person or Group column is called 'Manager'.



Code  Steps:



<script type="text/javascript" src="../../JSLibrary/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../../JSLibrary/jquery.SPServices-0.4.8.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
   var managerName;
  var userName = $().SPServices.SPGetCurrentUser();
    operation: "GetUserProfileByName",
    async: false,
    AccountName: userName,
    completefunc: function (xData, Status) {
managerName = $(xData.responseXML).text();
var managerLength = managerName.length;
var indexofManager = managerName.indexOf("Manager");
managerName = managerName.substring(indexofManager+13,managerLength);
var indexOffalse= managerName.indexOf("false");
managerName = managerName.substring(0,indexOffalse);
var peoplepicker = $("tr:contains('Reporting Manager'):last").find("div[title='People Picker']");

The available values from GetUserProfileByName in sharepoint 2010 environment are:


·         UserProfile_GUID

·         AccountName

·         FirstName

·         LastName

·         PreferredName

·         WorkPhone

·         Office

·         Department

·         Title

·         Manager

·         AboutMe

·         PersonalSpace

·         PictureURL

·         UserName

·         QuickLinks

·         WebSite

·         PublicSiteRedirect

·         SPS-Dotted-line

·         SPS-Peers

·         SPS-Responsibility

·         SPS-Skills

·         SPS-PastProjects

·         SPS-Interests

·         SPS-School

·         SPS-SipAddress

·         SPS-Birthday

·         SPS-MySiteUpgrade

·         SPS-DontSuggestList

·         SPS-ProxyAddresses

·         SPS-HireDate

·         SPS-LastColleagueAdded

·         SPS-OWAUrl

·         SPS-ResourceAccountName

·         SPS-MasterAccountName

·         Assistant

·         WorkEmail

·         CellPhone

·         Fax

·         HomePhone



Summary :

In this article we get Current user manager name and assign New/edit /display form using client side jquery and  SPServices .


 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend