0

I have users in string like "Mikhail Pushin" and I want to add clickable links to users in a column of list item. Also I should be able to use filtering on this user column.

Unfortunately, I can't do it the obvious way using SPUser object, because I can't get it for some users which have no access to my site and hence are not visible in web.AllUsers, web.Users and web.SiteUsers.

What I tried

  1. Add AD group which has all the users to site, but this doesn't help, because a user should be logged in at least once before to be visible in web.*Users.

  2. Get ProfileBase object using

    UserProfileManager userProfileManager = new UserProfileManager(SPServiceContext.GetContext(SPContext.Current.Site));                       
    ProfileBase[] userProfiles = userProfileManager.Search("Mikhail Pushin");
    

    This way I can find a user, but it seems there is no way of converting ProfileBase object to SPUser.

  3. Created a link to a user manually by using Note field and HTML's A tag. In the HREF attribute I set link obtained from ProfileBase. This way works well; however, in such a case I can't using OOB filtering on this column (which works for text and user columns if we click on the header).

Probably, some of you have ideas how I can achieve my goal. Every suggestion is very appreciated.

1 Answer 1

0

Once you have the ProfileBase object you can use the PublicUrl property to return the link to the user profile. You will have to handle the case where the user does not have a user profile.

Another approach is to use REST or CSOM against the UserProfile GetPropertiesFor endpoint. http://msdn.microsoft.com/en-us/library/office/jj163800.aspx

3
  • Thank you for the comment, Matthew. Now I use this approach, but unfortunately I can't use OOB filtering on column with this approach (it doesn't work with Note column, which I use to show link to the profile). Filtering is one of my tasks. Do you have any ideas?
    – MikhailSP
    Commented Nov 27, 2013 at 12:32
  • Can you add a web part that handles the filter? I am not exactly clear on what you are attempting. Another approach would be to use two fields instead, or add a custom field render template. Commented Nov 27, 2013 at 12:44
  • I can try to add a web part for filtering or use other approaches, but I would like to ensure that there is no way of using OOB filtering in my case. It seems like it is the case and I have to implement custom filtering or use other workarounds. Thank you for you answer!
    – MikhailSP
    Commented Nov 27, 2013 at 12:49

Your Answer

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

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