I'm attempting to create a new user profile section programmatically but without success. The problem is with the Type property of the Property class.
When I specify a value such as "section" for this, I receive the exception Data Type is not available for section. When I don't specify a value, I receive the exception UserProfilePropertySettings object must have a value set for 'Type'.
Here's the code:
var userProfileConfigManager = new UserProfileConfigManager(ServerContext.GetContext(site));
var propertyCollection = userProfileConfigManager.GetPropertiesWithSection();
var newProperty = propertyCollection.Create(true);
newProperty.Name = "NewSection";
newProperty.DisplayName = "NewSection";
newProperty.Type = "section"; // or not set
newProperty.IsUserEditable = false;
newProperty.Length = 0;
newProperty.DefaultPrivacy = 0;
newProperty.PrivacyPolicy = 0;
newProperty.IsSearchable = false;
newProperty.IsVisibleOnEditor = false;
newProperty.IsVisibleOnViewer = false;
newProperty.Separator = MultiValueSeparator.Unknown;
newProperty.Commit();
Any ideas?