2

I defined a multi value string for user profile properties in the backend of my SharePoint 2010. I'm reading the content from the created property like this: propertyValue = profile[propname].Value.ToString(); unfortunately i'm getting only the first stored value of the multi value field.

profile in the code is of type UserProfile and has GetUserProfile(accountName) from the UserProfileManager in it

Any Ideas how to get all multi values?

1

The profile property is actually a UserProfileValueCollection.

e.g.

UserProfileValueCollection propertyCollection = profile[propname];
foreach(var prop in propertyCollection)
{
    Console.WriteLine(prop.ToString());
}
  • Are you sure that UserProfilePropertyCollection exists? Doesn't work for me and i can't find anything on the internet about it.. – Peter Oct 21 '11 at 16:03
  • On the top of my head it's UserProfileValueCollection in stead of UserProfileProperyCollection – Anita Boerboom Oct 21 '11 at 18:55
  • Sorry, I was working off 2007... If you use 'var' it should work ok... – SHug Oct 21 '11 at 22:12
  • Just tested it - my code looks like this: ` if (profile[propname].Value != null) { UserProfileValueCollection propertyCollection = profile[propname]; propertyValue = propertyCollection.ToString(); } else { propertyValue = String.Empty; } sectionProperties.Add(propDisplayName, propertyValue);` still there ist just one Value inside of the propertyCollection – Peter Oct 27 '11 at 13:30
  • Edited per suggestion – SPDoctor Dec 29 '12 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.