0

In SharePoint 2010, I have created a custom user profile property named "MyCustomTools" in central admin as user Administrator.

Then I went to central admin and edit user profile and added vales in "MyCustomTools" as "Google;Facebook".

Now I want to retrieve values of custom properties like Google as link with url and Facebook as link with url. I am able to retrieve custom property name using below code:

new protected void Page_Load(object sender, EventArgs e)
        {
            using (SPSite site = new SPSite("servername"))
            {
                SPServiceContext context = SPServiceContext.GetContext(site);
                ProfileSubtypeManager psm = ProfileSubtypeManager.Get(context);
                ProfileSubtype ps = psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User));
                //Get the properties
                ProfileSubtypePropertyManager pspm = ps.Properties;
                foreach (ProfileSubtypeProperty profileSubtypeProperty in pspm.PropertiesWithSection)
                {
                    if (profileSubtypeProperty.Name == "MyCustomTools")
                    {
                        Label1.Text += profileSubtypeProperty.Name;
                    }
                }
            }
        }

but I need to retrieve values.

1 Answer 1

0

Getting the value is pretty straight forward though this is best answered by looking at the code in this other question on this forum. That question is a little bit different from this one but provides a good example.

The .Value property will return a UserProfileValueCollection that you can iterate through to get the individual values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.