Thursday, 19 August 2010

Export history of versioned field

Today's new puzzle involves a user who has a list where one of the elements is a multiline text field with "Append text to existing entries" (i.e. versioned field) used for an Audit trail. If you open an individual item you can see all entries made in that field. The view for that column displays only a 'View Entries' link for that column which when you click it opens the item and jumps to that field. If you export the view to Excel it only exports the most recent entry in that field.

The user wants to export the view and get all entries in the field.

UPDATE 1: Found solution for displaying all entries in an "Append text..." field. The resolution is to use a DataView in Sharepoint Designer and look in the code for the entry for the field you;re interested in then locate a line that looks like:

<xsl:value-of select="@Audit_x0020_trail_x0020_comments" disable-output-escaping="yes"/>

Where, in this case, @Audit_x0020_trail_x0020_comments is the name of the field. Replace this line with:

<SharePoint:AppendOnlyHistory runat="server" FieldName="Audit_x0020_trail_x0020_comments" ControlMode="Display" ItemId="{@ID}"/ >

Note that I had to drop the @ symbol from the field name else I got an error about an unhandled exception due to an Object Reference not being set.

This left two issues, one of which we've solved (or at least worked around) and the other we have not (actually there's a third one of how to get this past my boss who is wary of allowing things that involve direct editing of the code but if it's the only way it's the only way).

The solved issue is how to get a Dataview created in Sharepoint designer into the list of available views (labelled 'Views') at the right hand end of the Sharepoint List toolbar. Our workaround is to create a regular public view in Sharepoint then edit the resulting .aspx file in Sharepoint designer (delete the existing view and insert a Dataview, don't forget to go into Dataview Properties and check the Sharepoint List Toolbar checkbox).

The as yet unresolved issue is that if you try to export a Dataview to Excel it will only export the ID column and will give a message about Hidden or Read-Only columns that require data but have no defaults. One of the people commenting on the above linked site also reported this problem. Interestingly if we just create a dataview in a blank page, rather than putting it on an existing list page we get a different error message ("Unexpected error...your data could not be saved") and nothing gets exported at all! This also happens when we create a view with just the most basic of fields and no customisations.


Posted a question about this to a help forum:


Just tested with a different list on a different subsite, got exactly the same results so it looks like it's not related to the list we're using or the fields on it (this list is just a text field and a date).


Posted a question about this on Microsoft Technet. Had a reply, and follow ups, from someone.

No comments:

Post a Comment