Adding Comments to a List Part 1

In SharePoint 2007 the only lists that offer a comments feature are the posts list in the Blog site template. Wouldn’t it be nice to allow people to post comments on other types of lists like announcements or documents? Well after lots of trial and error I figured out how to do it.

What you will need

  • Two Lists
  • SharePoint Designer
  • Basic knowledge of HTML

I’ll assume you already have a list setup on which you want to allow users to comment. For this example I will use a standard Announcements list.

So the first thing we need to do is create a list to hold our comments.  I just used the following columns:

  • Title
  • Body
  • Post  (lookup to main list’s ‘Title’ column)

In the main list you will need to add a column that points back to the comments list.

  1. Go to the list settings page and click ‘Create Column’
  2. Name the column ‘Comments‘ (the name does not really matter. Set the type to ‘Lookup
  3. The lookup should get information from the comments list you created.  The column should be set to the lookup column in the comments list.  See the screenshot below. This column will show us the number of comments each item in our list has. 

Ok so now that we have the two lists pointing to each other we need to show the comments on a page with our list item.

  1. Add a couple of items to each list just for testing purposes.
  2. Create a blank web part page.
  3. Add a data view web part to the page to display the Annoucements list.
  4. Create a parameter on the dataview named item and set it to get the variable from the query string.
    Note : Whatever link user click to get to this page will need to pass the item ID as a variable in the query string in order for this solution to work. In my example I am passing the ID in the ‘item’ variable but you can use whatever you want.

    set up parameter
  5. Adjust the filter settings so that the list is filtered using the parameter that has been created. You can test to verify this is working by putting “?item=1” and the end of the url and the list item with an ID of 1 should be displayed.

    Filter using the parameter
  6. Add a web part to the page below the data view to display your comments list. Create a web part connection to filter the comments list based on the Title of the Annoucement list item.
    Get Sort Filter from
    Click Next

    Test the page and you should see one annoucement and the related comment.  In my next post we will create a form so that users can create new comments.

davecavins

Dave is a SharePoint developer and graphic designer based in the DC area.

3 thoughts on “Adding Comments to a List Part 1

Leave a Reply

Your email address will not be published. Required fields are marked *