views:

17

answers:

1

I want to modify a taxonomic user profile property in Sharepoint 2010. Just as an example, let's say I wanted to modify the Interests property (aka SPS-Interests, or PropertyConstants.Interests). I tried setting the property value with the semicolon-delimited string, like this:

var property = profile[PropertyConstants.Interests];
if (property != null)
{
    property.Value = "sharepoint; stackoverflow; scotch";                    
}

But that throws an exception.

A: 

I don't know for SharePoint 2010, but in 2007, profile[propertyName] is a UserProfileValueCollection, so it can contain multiple values.

This may work:

profile[PropertyConstants.Interests].Clear();
profile[PropertyConstants.Interests].Add("sharepoint");
profile[PropertyConstants.Interests].Add("stackoverflow");
profile[PropertyConstants.Interests].Add("scotch");

In 2007, you also need to call the Commit method on the userprofile to save the changes to the DB.

Tom Vervoort
Doh! That's a good forehead slapper. Thanks, Tom.
breischl