Jaa


Updating UserProfile Property of type ChoiceList

What I found from my research is, before updating the “ChoiceList” set the “MaximumShown” property to a higher value (depends on how many items you are adding).

e.g.

 

using (SPSite site = new SPSite("https://servername"))

{

ServerContext context =

ServerContext.GetContext(site);

UserProfileManager m_mngr = new UserProfileManager(context);

PropertyCollection props = m_mngr.Properties;

Property location = props.GetPropertyByName("CountryList");

Location.MaximumShown = Location.MaximumShown +1;

property.ChoiceList.Add("India");

property.Commit();

}

}