Ok, so i was aked to program against the userprofileproperty choicelist.
The choicelist is the property of a userprofileproperty, when the userprofileproperty is a choicelist (sounds logic, not ?)
First i created a user profile property of the type choicelist.
I created a piece of code to connect to the userprofiles and retrieve the specific property. After retrieving the property, i retrieved the values of the choicelist.
Unfortunately, these values are “simple” strings without any form of ID. At least, not through the api.
I had the property object, next thing > add the value(s) AND don’t forget : programmed the commit.
I ran the code, and no errors, however, also no added values.
After some debugging and digging, i found out that adding value to the choicelist is not considered a change for profileproperties.
Funny ? NOT!
Then let’s create a workaround. Before committing , i programmed some code that forces the state of the property to : changed.
That way the values where added together with the change that in fact, wasn’t a real change.
Please notice the portion regarding the description
ServerContext sc = ServerContext.GetContext(curSite); UserProfileManager upm = new UserProfileManager(sc); Property p = upm.Properties.GetPropertyByName(Propertyname); p.ChoiceList.Add(Value); string descript = p.Description; p.Description = ""; p.Description = descript; p.Commit()
after using this addition, the values where added succesfully to the property.
Hope this might help others.