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.
You’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.
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.
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
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.
Took a couple hours yesterday of trial an error but got it working. What tag do you use to post code in here?
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
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.
Randy, I get the same message, I was wondering how you fixed the issue?
Hi Steve, It was user error, :) I had a type in my code. I think i forgot a the @ beside my variable.
Did you ever figure out how to make the append changes to text work in the SharePoint folder context? I saw this post on which you commented and was having the same problem at that time: http://social.msdn.microsoft.com/forums/en-US/sharepointgeneralprevious/thread/54c4b787-1551-49c4-a7bc-854720a80e46
Have you ever been requested to have the ability to retrospectively edit appended notes?
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.
this rocks! thank you!
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.
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
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.
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
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.
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!
Ron:
DVWPs are still there in SharePoint Designer 2013. However, without the Design View it is a lot harder to use them. See: SharePoint Designer 2013′s Missing Design View – Still.
The “modern” way to accomplish what we’ve traditionally done with DVWPs is Display Templates, REST, CSOM, etc.
M.