Showing Sharepoint Appended Comments in a dataview webpart

I searched for hours on this one when I came across a few good posts.  The first one I came across talks about using a custom form in display mode to show all of the history from an “Append Changes to Existing Text” field.  Here is a link to that post:

http://unitedsupplyco.sharepointsite.net/publicfacing/bensblog/Lists/Posts/Post.aspx?ID=41#Comments

The author suggests that he/she doesn’t know how to make this work in a dataview webpart.  When I tried this, I got this error:

object reference not set to an instance of an object

I would have likely lived with a custom form as the solution, however since it didn’t work for me, I continued to search.  Next I found a post that basically gives the same solution but this time in a dataview webpart! That post is here:

http://sympmarc.com/2011/02/07/showing-all-versions-of-append-changes-to-existing-text-in-a-data-view-web-part-dvwp

Awesome, except I was still getting an error.  Both posts suggest the solution is to replace the xsl line:

<xsl:value-of select=”[your column name]” disable-output-escaping=”yes” />

with this line:

<SharePoint:AppendOnlyHistory runat=”server” FieldName=”[your column name]” ControlMode=”Display”/>

You should, obviously, replace the [your column name] with the name of your SharePoint column.  Since this was the same solution in both posts (one in a custom form webpart and the other in a dataview webpart), I knew my error message must be from something I’m missing.

Then I figured it out through trial and error.  When I replaced my column name – I took the name from the xsl line – in my case it was {@Project_x0020_Notes} – and put it in the new non-xsl line.  That is when I get the error message.  So I tried removing the curly brackets – no luck.  I tried removing the @ sign – still no luck.  Then, in a total shot in the dark, I tried using the SharePoint friendly name “Project Notes” instead of the xsl formated name Project_x0020_Notes.

BAM! That worked and now I can display all the appended comments in a dataview webpart!  Hope that helps you!

 

5 thoughts on “Showing Sharepoint Appended Comments in a dataview webpart

  1. TCS

    Fantastic! Switching from the internal name to the friendly name did the trick! I’ve connected two web parts so the user can select, from a list of projects on the left, which one she wants to see details for in a web part on the right. (The right side web part contains the field for which I want history.)

    Thanks for the tip, dsackr!!

    Reply
  2. Justin Morgan

    I can confirm that it does work in SP2010.

    I used this:

    with the “friendly name” as suggested: That is when I get the error message. So I tried removing the curly brackets – no luck. I tried removing the @ sign – still no luck. Then, in a total shot in the dark, I tried using the SharePoint friendly name “Project Notes” instead of the xsl formated name Project_x0020_Notes.

    My final working line looks like this:

    Nice and simple! Thanks for the post!
    Justin

    Reply
  3. Chris

    Hello,

    Have you got this working in SharePoint 2010?

    I have added the line and don’t get an error message when I preview the page – just doesn’t display the appended text field as expect.

    Cheers,

    Chris

    Reply

Leave a Reply