Solved

sharepoint 2010 userproperty "SPS-HireDate" is not working

Posted on 2011-02-28
2
1,369 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

679 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