Solved

sharepoint 2010 userproperty "SPS-HireDate" is not working

Posted on 2011-02-28
2
1,308 Views
Last Modified: 2013-11-25
Hi,
I am trying to access "SPS-hireDate" property from code.

But I can't able to open my webpart because it is showing error.



                         if (userinfo["SPS-HireDate"] != null)
                         {
                             lblOutput.Text += "<tr height='20px'><td style='padding-left:10px;color:#000000;font-weight:bold;font-style:italic;font-size:11px;font-family:Arial, Helvetica, sans-serif;'>" + userinfo["SPS-HireDate"].ToString() + "</td></tr>";

                         }
                     
 i am attaching all code for this webpart
Error--SPS-HireDate.png
UserInfo.cs
0
Comment
Question by:smskareem
2 Comments
 
LVL 4

Accepted Solution

by:
Pstry earned 125 total points
ID: 35007134
The 'SPS-HireDate' field does not exist in UserInfo list.

Use user profiles instead:

ctx = SPServiceContext.GetContext(SPContext.Current.Site);
manager = new UserProfileManager(ctx);
profile = manager.GetUserProfile(web.CurrentUser.LoginName);
Console.WriteLine(profile["SPS-HireDate"].ToString());  // Check for NULL first !
// or, better:
Console.WriteLine(profile[PropertyConstants.HireDate].ToString());  // Check for NULL first !
   
0
 

Author Closing Comment

by:smskareem
ID: 35015001
Thanks a lot !
Very helpful and clear.

i need 1 more thing ...like in given url
http://msdn.microsoft.com/en-us/library/ms519896.aspx

using (SPSite site = new SPSite("http://servername"))

So what is actual "server name"?

is it a url of Central Admin or url of any site or only "computer name"?
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now