Question

My user profiles have some custom properties. Now I need to get a list of all values that this custom property has on any user. This code return an error that "Column 'Division' does not exist. It may have been deleted by another user".

Is this the right approach? There is many users and possible many distinct values.

 SPListItemCollection userInformationList = SPContext.Current.Web.SiteUserInfoList.Items;
  var divisions= (from SPListItem userItem in userInformationList.Items where userItem["Division"] != null select userItem["Division"]); 
Was it helpful?

Solution

Check the GetUserProfile from UserProfileManager. You get the whole object, should be the right spot to search for a list of all custom properties..

i'm working on an almost simliar webpart.. im trying to display only a couple of custom properties..

hope to help

http://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.userprofilemanager.aspx

OTHER TIPS

First of all never ever use LINQ in this way in SharePoint! You will retrieve the full user information list from the database when hitting the .Items property! Instead use a CAML query to "search" for the users using the SPQuery object.

I would recommend that you use the U2U CAML Query builder to build your query - using that tool you will get the correct columns and column name.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top