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. Very helpful, thanks. For our project status reports, we would like to maintain the history but display only the last entry. Any suggestions?

    1. Doris,
      Did you ever find a solution to just display the last entry in a column that has “Append Changes to Existing Text” set on?

      I found that I could get it to work with when comments were required. However if the comments are not required this method shows nothing and

      shows every entry.

  2. Marc,

    Fantastic! Worked perfectly. So nice to get a solution with only a couple of google searches.

    Terry

  3. Hello Mike,

    Your solution worked perfectly for me to display comments for each document in Dataview webpart.Thanks a lot!!

    Now my issue is if there is no version created for given Item e.g. No comments made on document so it just have ‘No existing entries.’ then I do not want to display that item in Dataview.

    Only Items with comments added should be display not the empty version.Any help would be appreciated.

    Thanks,
    Anjalee

    1. Anjalee:

      I don’t think that there’s a way to do that, but it might just not be something anyone’s turned up yet. Because you are asking SharePoint to generate to output using the control, you don’t have any control over the output formatting.

      The only trick I can think of is to hide the “empty” comments with CSS and/or script client-side.

      And it’s “Marc”. ;+)

      M.

  4. Has anyone accomplished this within a data view of a SharePoint list that exists on another site? I’m getting something similar to what Scott got above – Error rendering control – Unnamed ##.

    I’m not much of a coder so any cheats you can provide on the syntax would be much appreciated :)

    1. Jeff:

      I don’t recall having tried this on a list in another site myself, but I *think* it ought to work. Do you have the WebURL parameter set correctly?

      M.

  5. Has anyone successfully pulled the AppendOnlyHistory fields into SQL Server Reporting Services? Any SharePoint list column I have configured this way comes back empty in SSRS.

  6. Hi this worked fine for me in Sharepoint Designer 2010 but when I try and view in the browser I get this error message:

    Cannot create an object of type ‘System.Int32’ from its string representation ‘{@ID}’ for the ‘ItemId’ property.

    Any ideas?

    1. Caroline:

      Hmm. I haven’t seen that before with this technique, but I’m also not sure I’ve done it in SharePoint 2010. It’s similar to the message you get if you don’t convert a value to a string in the ddwrt functions, so try this:

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

      M.

  7. Thanks Marc.

    It was actually an issue with the Dataview webpart not your line of code. I recreated it and its working perfectly in 2010.

    Thanks for the help.

    1. Caroline–

      I’m getting the same error that you got. What was the issue with your Dataview webpart? How do I know if my issue is the same as yours.

      So far this solution looks like the “holy grail” of getting rid of [View Entries…] I am feel so close but can’t quite get there. Please help me with some more detail. Please

      Thanks.

  8. i have the follow:

    I tried

    in dataform webpart, but not work for me, show this error. Error Rendering Control – Unamed1 An unhandled exception has occured. Operation is not valid due to the current state of the object.

    I use the dataform webpart in subsite that not contain the list used. The list is in the root site. Any suggestions?

    1. hi
      I’m having same problem with dataforwebpart, basically nothing displays in coloumn with ‘Append Changes to Existing text’. Did you manage to find a solution to this?

      1. In a SP2010 DVWP with linked datasource (aggregate datasource), try adding to the control’s XSLT the parameter ListId=”GUID” where GUID is your list’s identifier, without the curly brackets.

  9. Thanks Marc. It works for me. However, the comments only appear in SharePoint Designer and not SharePoint. Do you know what I need to do for the comments to appear in the Data View Web Parts in SharePoint as well?

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.