SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If a user has posted to various discussions across a SharePoint web application, how can I get the posts they have made in order to populate a web part (using C#)? Also is it possible to get topics most viewed or replied to? Wanting to do a home page would be something like this:

My Topics                   Popular Topics
Topic        Replies        Topic                  Replies
=====        =======        =====                  =======
My Topic     4              Something interesting  120
My Topic 2   0              Not as interesting     40

Need to know the API's to use more than the actual HTML/CSS code to write.

share|improve this question

You should be able to just run a query with SP.list. I haven't really done any work with discussions in 2010, but my understanding is that it's fairly unchanged from 2007. There should be a post count (or similar) column. I have done this in 2007 with a DVWP. You can use the U2U CAML Query tool to determine what the column name is.

In short, I don't think you should have to do anything complex (nothing outside of a straight query anyway).

share|improve this answer

You might be able to use an SPSiteDataQuery to query the site collection, looking for messages or discussions that were posted by the user. I think that Discussions have a content type beginning 0x012002, replies have the type beginning 0x0107

Similarly, I'd use an SPSiteDataQuery to get just Discussions, and order the results - but I'm not sure what field to order by, as I'm not sure what would hold the 'count' of the replies.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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