It’s unlikely that the word ‘collaboration’ would be missing from any high-level description of SharePoint. Collaboration is supposed to be one of the main benefits of SharePoint and it is; however, sometimes SharePoint makes it harder to collaborate than it really should be.
Take a ‘Multiple lines of text’ column with Append Changes enabled – this is a great feature as it allows you to have a conversation right in a list item. Who said what, when they said it and what they said is captured for all to see – just like in a forum (if you are not familiar with this feature, don’t worry – I will explain how to enable it in the steps below).
In this post I will describe how to get these comments and the associated metadata to appear in a ‘view’ – you will need SharePoint Designer 2013 for this. I will be applying the changes to our free SharePoint project management templates, but you should be able to follow the steps in your own SharePoint site or in the full BrightWork product.
The crux of the problem I am addressing today is that when you add an Append Only column to a view, you can’t see any of the entries, instead what you see is a “View Entries…” link that opens the item – not great if you just want to scan the list for recent comments.
Wouldn’t it be great if you could see the comment history for multiple items simultaneously – just like in the image below? You can do this with the Data View Webpart and SharePoint Designer – read on to find out how. Hat-tip to Marc D Anderson for setting me on the way to solving this.
Add Append Only Column
Just in case you are unfamiliar with the Append Only Column, see below for how to enable it. If you already have such a column in your list, you can skip ahead to the next section.
- Go the the List Settings page and click Versioning settings.
- Select Yes to enable versioning for the list and click OK.
- Add a Multiple lines of text column to your list and select Yes beside Append Changes to Existing Text.
Tip: Unselect Add to default view as you will just get the not very usable View Entries bit you can see in the image above.
Enable Comments in Data View Web Part
In this section will describe how to get the comments into a view.
The Data View web part is one of those hidden SharePoint gems that not many people know about, mainly because you really need SharePoint Designer to get the most out of it. With Design View gone in SharePoint 2013, it gets a little (maybe a lot) harder to work with, but you can still do most of what you used to be able to do.
- Create a new page in the Site Contents library (any web part or wiki page will do).
- Open the page in SharePoint Designer.
- Click Advanced Mode to enable code editing.
- Click between the two Zone Template tags.
- Click Insert | Data View | Empty Data View.
(Selecting a specific list inserts a List View web part, which we can’t use here) - Click between the Data Sources tags.
- Click Insert | Data Source | Project Tasks.
- Select the Task Name column in the Data Source Details panel and click Multiple Items View on the Insert Selected Fields as menu.
- Click Add/Remove Columns.
- Add the columns you want to add and click OK.
- Click F12 on your keyboard and Yes twice to view the page in your browser – you will notice that View Entries displays!
- Return to SharePoint Designer and find the XSL that relates to the Comments column – it is high-lighted in yellow below. An easy way to find it is to search for “td class=”ms-vb”.
- Replace the XSL (the bit high-lighted in Yellow with the below code and make sure that the field name matches what was displayed after the @ sign in the XSL (‘Comment’ in this case).
<
SharePoint:AppendOnlyHistory
FieldName
=
"Comment"
runat
=
"server"
ControlMode
=
"Display"
ItemId
=
"{@ID}"
/>
- Click Save and when you refresh the page you should see all the comments in the data view!
Update 1 – Fix AssignedTo Issue
Thanks to Jordon in the comments for setting me on the right path to this.
Essentially, you must replace the XSL for Assigned to with the below code.
<SharePoint:FieldValue FieldName=”AssignedTo” runat=”server” ControlMode=”Display” ItemId=”{@ID}” />
Limitations
Unfortunately, we don’t get all the options we normally get in a standard view. Really all I was able to get was the ability to see all Comments in all items in a list. When I added the Assigned To column, I got a weird error where a lot of code was also displayed (see image below).
What I would really like to be able to do is show the comments in a standard view, with the list item menu and so on, and be able to opt to only show the last comment or the last two comments.