HiddenNetwork.com Banner
Showing posts with label User Profiles. Show all posts
Showing posts with label User Profiles. Show all posts

Monday, March 10, 2008

Aha! User profile choice list commit - I told you so

This just in: KB948724 - "Changes are not committed when the Commit() method is called in SharePoint Server 2007 or in SharePoint Portal Server 2003" that was published yesterday (thank you KBAlertz for letting me know) affirms what I have written about a year and a half ago.
The Microsoft article describes a workaround (that me and the guys have already found, but I never got a chance to blog about.

Short story - if you try to do this:
property.ChoiceList.Add("test");
property.Commit();
It won't work.
Workaround - "To work around this problem, modify another property that is not a ChoiceList property. Then, call the Commit() method. The changes to the ChoiceList property will be committed."

Thursday, January 10, 2008

Getting user profile values that support multiple value

I noticed today that the MSDN article "User Profiles Object Model Overview" has a wrong code sample for the "correct way of retrieving a user profile property value". The code sample there will not work, because the object model in sharepoind doesnt have the methods and objects the sample code is using.
Therefore - here is my correct way:

if (Profile[this.UserProfilePropertyName].Count == 1)
    return Profile[this.UserProfilePropertyName].Value.ToString();
else
{
    StringBuilder ret = new StringBuilder("");
    UserProfileValueCollection values = Profile[this.UserProfilePropertyName];
    System.Collections.IEnumerator allValues = values.GetEnumerator();
    while(allValues.MoveNext())
    {
        ret.Append(allValues.Current.ToString());
        ret.Append(";");
    }
    return ret.ToString();
}