Question

i want to programatically fetch all users(list of users) who have a tagged a sharepoint 2010 custom list item "i like it".

this thread shows how to get count of user who have tagged a list item with "I Like it"

but i want list of users // sharepoint provide this functionality out of the box in central admin for this follow this link

is there any way to fetch this information programatically ??

thanks in advance!!

Was it helpful?

Solution

While I'm sure folks will assert that querying the database in any form is not allowed (i.e. will affect your Microsoft supportability), I will challenge them ahead of time to produce anything officially from Microsoft with such a statement. All kinds of stuff on inserting/modifying/deleting rows in tables and altering the scheme, but nothing on performing a select statement or executing a stored procedure that doesn't update the table contents in any way.

I will say that directly querying the database is something that should be done by folks that a) understand SQL and how it optimizes queries and b) understand the SharePoint DM. You don't want folks writing queries that will have a measurable negative impact on a farm's performance.

With that disclaimer out of the way, there is no OOB means of getting to this data via a published and supported API that I am aware of. You could get to it by stringing a few of the Social DB's stored procedures together, but it's kind of cumbersome. The following is a Select that will get you most of the way. You would still need to link it to your Profile DB to resolve the GUID to a profile name...you could alternately tzake the GUID and call UserProfileManager.GetUserProfile to return a reference to the profile and get the name that way.

SELECT UserId
FROM [Social DB].[dbo].[SocialTags] st 
  Inner Join [Social DB].[dbo].[Urls] u 
    On u.UrlId = st.UrlId 
    and u.Url = 'http://sharepointdev:9000/Shared%20Documents/Content_viewing_2011-07-26T131806.xlsx' -- the encoded URL of the file you want to retrieve Like It info on
  Inner Join [Social DB].[dbo].[UserProfile_Validation] uv 
    On uv.User_RecordID = st.User_RecordID
Where
  InputTermLabel = 'I like it' -- or you can get the TermID for the "I Like It" tag and query against TermID

Not a perfect solution by any stretch of the imagination and one that will obviously require re-certification if any hotfixes, CU, or SPs are installed.

OTHER TIPS

In the first post, have you tried enumerating the List<SocialTermDetail> list to see what's in each object in the list?

In this magazine: http://www.diwug.nl/e-magazines/pages/default.aspx eMagazine #4 I wrote an article about the SocialDataService, UserProfile, Users and Groups and the Search web service. I guess this will help you.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top