ProfileProperty: Change the display order of a existing Userprofile Property

by Christoph Keller 3. January 2011 14:26
Because of the fact that the SharePoint way of changing the userprofile propery order is a pain, here is the coding-way doing this task: string siteUrl = "http://SITEURL"; using (SPSite localSite = new SPSite(siteUrl)) { SPServiceContext serviceContext = SPServiceContext.GetContext(localSite); int displayOrder = 10; ProfileSubtypeManager psm = ProfileSubtypeManager.Get(serviceContext); ProfileSubtype ps = psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User)); ProfileSubtypePropertyManager pspm = ps.Properties; // update display order of the property pspm.SetDisplayOrderByPropertyName("PROPERTYNAME", displayOrder); // important: commit the display order! pspm.CommitDisplayOrder(); } You need a instance of the local SPSite. With this, get a SPServiceContext instance.Then you need a ProfileSubtypeManager instance (the ordering is managed by the ProfileSubtypeProperty out of the ProfileSubtype). and finally a ProfileSubtypePropertyManager. To Update the displayorder finally, don't forget to call the "CommitDisplayOrder()" function.
DotnetKicks
DotNetShoutout

Tags: ,

Sharepoint