Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.