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. This looks great and would love to use it but does not work for me.
    I’m using SP 2010. I created a DataFormwebpart and added a couple fields and the Appended text field. The place in the code where the append text field lives:
    xsl:value-of select=”@Case_x0020_Notes_x0020__x002f__x”/>
    I replaced it with:

    I get this error:
    Error Rendering Control – Unamed1
    An unhandled exception has occurred. Object reference not set to an instance of an object.
    This error replaces the Appended text feild and occurs on each row, Each row has ….Unamed2, Unamed3 . . .etc

    1. Randy:

      It sounds like you’ve got something wrong in your XSL. It ought to work. As you can see, your code didn’t make it through. Post it somewhere and I’ll take a look.

      M.

  2. I’m getting an error – rendering unnamed I have this in SPS2007, it is a dataview at this time only two columns are showing the ID column and the multi-lined text column that contains the items I want to show. This is strange I have the code working in the Displayform.aspx page, but I need it in a Dataview or ? that will allow the end client to see all the items in the list and then export it to excel

    1. Hard to say, Steve. The exporting to Excel piece complicates this a bit. A DVWP won’t give you that capability; only the standard list views give you that.

      M.

    1. Nope. That’s really not how this functionality works.

      For what you describe, I think you’d need to manage the comments in a separate list as child items.

      M.

  3. A poor man’s solution is to create another field i.e. “Last Comment” Then use a workflow to update that field if your comments field is not blank after each edit. Just remove the “Last Comment” field from the content type. Then you can use that field in a regular web part.

  4. Hello Marc –

    Would you be able to recommend where this snippet be placed when updating teh XSL Template?

    Also, on a couple of attempts up update View with Designer to insert where I “think” I should, either the Desiger Message about ([suspected] malicious code will be altered or removed) or the Master (some other?) templated takes out what I have put in and replaces it with what was there before…

    Thanx!
    Jeff

    1. Jeff:

      You need to put the line of code into the DVWP exactly where the value is currently rendered. In my example, it’s where the “Comments” column is emitted in the XSL.

      M.

  5. Hi Marc,

    I was delighted when I found your post about showing all versions of a multiline comment field. Yours was by far the most straight forward and I managed to follow all steps until the section replacing the XSL as I haven’t done this before.

    I use SharePoint Designer 2010. You wrote: “… 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: .

    The result shown in this post is exactly what I am looking for. My current situation is that I have a view showing all necessary field including comments with the default value ‘View Entries …’.

    Can you please provide a step-by-step guide on how to replace the XSL code above.

    Furthermore, do I have to change the value for FieldName (my comment field is named ‘Comments’ and/or runat=”server”?

    Much obliged.

    Greetings from Ireland,
    Christian Krummel

    1. Christian:

      I don’t have the time to write up the step-by-step, but there is plenty of information here on my blog, on other blogs, etc. about how to implement a DVWP. In my example, my column was named “Comments”, so you wouldn’t change that.

      M.

  6. Exactly what I’m looking for… how is this done in SP 2013? I don’t see Data View Web Parts there. Thanks for giving me hope!

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.