0

TLDR I've used this code <SharePoint:AppendOnlyHistory runat="server" FieldName="PublishComments" ControlMode="Display" ItemId="{@ID}"/>

To add a "Comments history" to a list. I've used sharepoint designer on a custom list. That code is for Item View, i've also added the one for edit.

My problem is that even if i create a new item, the history field will duplicate the comment. That also happens if i edit the item (the previous 2 comments show up in history and the new comment gets duplicated aswell so instead of 2 i've got 4 comments). I've searched online and i can't find anything relevant. Im using Multiple Lines of Text -> Enhanced riched text.

Any idea on how to fix the duplicates?

0

I found no way of fixing this in SharePoint so i did a workaround in jQuery (in case anyone needs it).

    $(".pubHistory div").each(function() {
        var txt = $(this).text();
        if (seen[txt]) {
            $(this).remove();
        } else {
            seen[txt] = true;
        }
    });

pubHistory class is for the parent TR, the div selector is there because each comment is inside a div. It loops through the comments and removes duplicates. I'll update this question if i ever find a way to fix it without jQuery.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.