Monday, August 29, 2011

Display “Append Changes to Existing Text” Fields in a Custom List Form Web Part

I want to thank Brian Hunsaker for pointing this out to me. I've posted several times about the difficulties I've had in the past with displaying text fields in custom web parts where the "Append Changes to Existing Text" option is turned on. An example of this is the comments field in the test issues list:

I still don't know how to get this to show up in a custom Data View Web Part, but at least, with Brian's help, I've found a line of code that will allow you to display comments with a custom list form. Here's how you add a custom list form and display the comments field within SharePoint Designer 2007. I created a blank Web Part Page as my starting point.
  1. After selecting the correct web part zone, go to Insert > SharePoint Controls > Custom List Form:

  2. For this example, I'm going to use the following options:

  3. Find the line of code that references your Comments field (the text field with "Append Changes to Existing Text" turned on). If you're viewing your site in split mode, all you have to do is click on the comments field in the design area of your site.

  4. Replace the line that begins <xsl:value-of … and replace it with the following line of code:
    <SharePoint:AppendOnlyHistory runat="server" FieldName="V3Comments" ControlMode="Display"/>
    FieldName is the name of your field and ControlMode is the type of mode you're using to display the data (so if your form is in edit mode, you may want to use "Edit.").
Now you will see this history of this field with user and date/time stamped!
Here's a link to an MSDN article that explains some of this (although I had trouble understanding it):