Custom Edit Form: Show Version History for “Append Changes to Existing Text fields”

February 24th, 2009 | Tags: ,

When you create a Custom Edit form using SharePoint designer, you lose the ability to view the version history for fields with the versioning enabled (lets say, ‘Comment’ field). To show this, do the following:

Insert the ‘Comment’ field again as a form field and change the code as below in the ‘Code’ view.

<SharePoint:FormField runat="server" controlmode="Edit" . . ./>

to

<SharePoint:AppendOnlyHistory runat="server" controlmode="Display" . . ./>

Now your comments history would start showing as in the standard form!

  1. Sanjeev
    June 24th, 2009 at 09:26
    Reply | Quote | #1

    When I install the code as you have described above, it gives me a Data Source Conflict. It looks like it is trying to save both inputs. Do I need to change anything else on the line of code? perhaps in the databind portion?

  2. jai
    June 27th, 2009 at 22:30
    Reply | Quote | #2

    Make sure the id of the new field is different and you did not copy the field.

  3. Jaroslav Kabrt
    February 3rd, 2010 at 04:51
    Reply | Quote | #3

    Thanks for great tip… and what about custom DispForm.aspx? Is there some way how to display old versions text too?

    Thanks in advance. #JK

  4. admin
    February 9th, 2010 at 07:03
    Reply | Quote | #4

    For DispForm.aspx, I did not have any problem. The same technique should work there also I think.

  5. Haresh
    March 15th, 2010 at 20:30
    Reply | Quote | #5

    Ref: Custom Display Form

    The above code displays the history, but at the same time; exposes the List Item history for the users to play with i.e date-time stamp is a hyperlink to the history item !!

    Any idea, how to remove the hyperlink and make the date-time stamp simple text with no hyperlinks.

  6. Haresh
    March 15th, 2010 at 20:32
    Reply | Quote | #6

    @admin

    Ref: Custom Display Form

    The above code displays the history, but at the same time; exposes the List Item history for the users to play with i.e date-time stamp is a hyperlink to the history item !!

    Any idea, how to remove the hyperlink and make the date-time stamp simple text with no hyperlinks.

  7. admin
    March 15th, 2010 at 23:53
    Reply | Quote | #7

    The field is an inbuilt sharepoint field. Will have to check how to manipulate it.

  8. Jaroslav Kabrt
    March 18th, 2010 at 07:46
    Reply | Quote | #8

    How should I use this method for displaying history information of fields on custom DispForm.aspx?

    I expected, that there will be the same , and tags like in custom EditForm, but there is only!
    I tried add, combine and replace this xsl tag with those from EditForm, but unsuccessfully :-(

    Any ideas?

    Thanks. #JK

  9. Jaroslav Kabrt
    March 18th, 2010 at 07:49
    Reply | Quote | #9

    Oups… comments form deleted written tags, so again:

    How should I use this method for displaying history information of fields on custom DispForm.aspx?

    I expected, that there will be the same SharePoint:FormField , SharePoint:FieldDescription and SharePoint:AppendOnlyHistory tags like in custom EditForm, but there is xsl:value-of select=”@MyField” only!
    I tried add, combine and replace this xsl tag with those from EditForm, but unsuccessfully :-(

    Any ideas?

    Thanks. #JK

  10. Scott Anderson
    September 1st, 2010 at 12:32

    Thanks! This was exactly what I was looking for for my DispForm.

  11. Steve Thomas
    September 4th, 2010 at 09:38

    I tried the above and it seems to work on the display form but when I add it to the Edit form I am no longer able to save updates to the field. You can edit the field but it doesn’t save the changes. Any idea what I’m doing wrong?

    Thanks, Steve

  12. admin
    September 5th, 2010 at 23:24

    I am using it for editing and it is getting saved properly. What type of field are you using?

  13. Carl
    November 2nd, 2010 at 05:09

    Hi, I’m having the same problem as Steve Thomas. When I add the list form field twice (changing the second one) no edits in the comments box are saved. If I remove the second one (now showing history) the edits are once again saved.

  14. Carl
    November 2nd, 2010 at 05:18

    I have got it to work. I removed all the rest of the text after and left it as it shows there. This now works ok.

    Thanks a lot for this, it has been a great help for me!

  15. Mark
    November 4th, 2010 at 19:09

    Hi Carl. Sorry to be a pain, but can you expand on exactly what you did and with which line of code?

    I’ve got exactly the same issue and (apologies if I’m being dense) can’t work out what you did from your description.

  16. Dave Patel
    December 23rd, 2010 at 17:01

    AWESOME…THANKS!!!!

  17. bedavaporno film izle
    February 18th, 2011 at 22:20

    i think there is some think more than this ? the situation is important but we need some more additional informations too? am i correct ?

  18. Gaya
    April 1st, 2011 at 09:46

    I tried the above and it seems to work on the display form but when I add it to the Edit form I am no longer able to edit the field. I can view the history on it but cannot update it. What am I doing wrong? Any help will be greatly appreciated.

  19. Alun
    July 4th, 2011 at 01:21

    Thanks for this – I also had the not saving problem but changed the whole code to

  20. Philip
    July 25th, 2011 at 11:10

    Am having the saving problem, and (like Mark) am not following what people have done to the code to get around this issue. Carl or Alun, could either of you describe more on what you did to fix this problem?

  21. Angelica
    August 5th, 2011 at 09:16

    This is the code that worked for me:

    Hope that helps.

  22. Angelica
    August 5th, 2011 at 09:18

    oops, code isn’t showing lol

    I used the code that Jai posted but also kept FieldName=”Comments” then the end tag

  23. Davetech
    November 9th, 2011 at 10:50

    Excellent guys, with your help i managed to get both edit and display working in Sharepoint Designer 2010

    For clarification so that it’s all in one place:

    Do the edit first.

    Firstly you need to copy and immediately reinsert the code representing the field you want to see history on and then change FormField to AppendOnlyHistory and the control mode from edit to display. AND in Sharepoint designer 2010 you also need to change the id [i added an h for history] – remember to change it all places in the code.

    Original:

    Inserted Code:

    Save and Test

    Then the display Form:
    Copy the inserted code from the edit form and strip out everything apart from what is shown below:

    and place it where you want the history to appear.
    That’s what i did and it is all working fine. hope it works for you. Good Luck!