Showing All Versions of “Append Changes to Existing Text” in a Data View Web Part (DVWP)

While flying across the country to SPTechCon SFO 2011, I was going through some of my old “blog posts I should do sometime” lists and came across this cool trick. Brendan Horner (@hornerit) shared it with me months ago via Twitter and I socked it away for one of those extra moments. Well, I found that moment. It’s not something which hasn’t been written about before, but it’s something I’m asked about from time to time, and I never remember how to do it, so here you go.

imageYou’ve probably used the “Append Changes to Existing Text” trick in a list at least once. If not, here’s how it works. You have to have versioning turned on for the list for this to work. Then if you create a Multiple lines of text column, at the bottom of the settings you’ll see the option.

image

Setting the option to “Yes” lets you keep a sort of running log in that column. I’ve used it many times in tasks lists so that each person can add their $.02 during the process. Here’s what it might look like (with some silly test data):

One problem with this cool functionality is that in views, you don’t get to see the strings of text, just a link that takes you to the DispForm for the item. It’s a cumbersome UI choice, for sure.

So naturally, we’d like to be able to turn to a Data View Web Part (DVWP) to improve the user experience. To make this work, you need to add the following line into your XSL:

<SharePoint:AppendOnlyHistory FieldName="Comments" runat="server" ControlMode="Display" ItemId="{@ID}"/>

When you do this, you get a nice listing of the history, like this:

Much nicer! Thanks, Brendan.

Similar Posts

106 Comments

  1. Hi,

    In MOSS 2007 this wasn’t giving problem at all, but in SharePoint 2010 it is eating my head, ok the new line is almost solved my problem but i want to show only the last history not all of them, please help

    1. If you only want to show the last version, then you may want to look at the Versions Web Service (I’m guessing).

      M.

  2. <SharePoint:AppendOnlyHistory FieldName="Comments" runat="server" ControlMode="Display" ItemId="{$thisNode/@ID}"/>

    Basically @ID was replaced with $thisNode/@ID

  3. Hi. I’ve been looking for a way to achieve this without using Sharepoint Designer which I don’t have access to. Does anyone know of another way to achieve this?

    1. Paul:

      I can’t think of an easy way. You could write script using SPServices to look into the versions. It’s doable, but probably more work. In fact, it might make a nice function for SPServices!

      M.

  4. Hi

    I want to export all my view entries to excel sheet

    At present when I Export the list to Spreadsheet I only get the last comment.

    How can i export with all comments. Is this possible?

    Thanks in Advance

    1. Kiran:

      Since “Append changes to existing text” uses versionng as the underlying mechanism, no there’s nothing available out of the box. As you’ve realized, only the current version is downloaded.

      M.

  5. Hi this worked for me. The only issue I have is it puts the name and date on one line and then puts the comment on the line below instead of on the same line as in your example. Any ideas how I can get the comments and name and date to all appear on the same line?

    Thanks

    1. I’ve actually worked this out. I was using a custom comments column instead I’m using the existing site column Append only comments and that displays as I wanted.

  6. The organization I support is still using SP 2007. I have tried referencing the code you supplied and use it via SP Designer 2007 on SP 2007 site and it does not appear to work. Will this work in a SP 2007 environment? Thank you

  7. Marc

    Thank you for your response. I am not sure where in the sequence to add the entry you provided and I’m not sure if you can provide any particular guidance without more specifics from me but is there a specific location I should place this entry?

    Thanks Marc,

    Jerry

    1. Jerry:

      Yes, it’s a little hard to be sure what to tell you, but you add the line

      <SharePoint:AppendOnlyHistory FieldName="Comments" runat="server" ControlMode="Display" ItemId="{@ID}"/>
      

      where you are currently displaying the column value in the DVWP. It’ll look something like this by default:

      <xsl:value select="@Comments"/>
      

      M.

  8. Marc

    Cannot thank you enough; I was able to get the comments to display. I have some other issues now but will deal with those one step at a time.
    Thank you again,
    Jerry

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.