Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

sharepoint 2010 userproperty "SPS-HireDate" is not working

Posted on 2011-02-28
2
Medium Priority
?
1,457 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 375 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Loops Section Overview

972 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