Solved

sharepoint 2010 userproperty "SPS-HireDate" is not working

Posted on 2011-02-28
2
1,404 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

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…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

627 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