Show the most recent comment from SharePoint text fields instead of “view items”

How to show the most recent comment instead of ‘view items’ in SharePoint lists

When you set up a SharePoint list you can create a text column that keeps a history of previous entries. You enable this by selecting Yes for the Append Changes to Existing Text column setting. This is handy for a comments field where you need to keep track of user comment history, for example.

The problem I’ve had is that when you put this column in a SharePoint view you wind up seeing a hyperlink with the text “view items”. This is not helpful. Further, the link always shows up – even when there are no comments or text in the column. This just makes for way too much clicking back and forth.

The solution

As a workaround, you can set up a helper column to mirror the most recent changes to your text field. To do this, you create a SharePoint List workflow to look for a change, and if found update the mirror column. The steps for this are outlined below. This has the added benefit of keeping the most recent comment visible, even if the record had subsequent updates where no new comment text was added.

Create the mirror column

Let’s say you have a column called Comments – and this is a multi-line text field with Rich Text enabled, and the Append Changes to Existing Text is set to Yes.

Create another column called Most Recent Comments. Make this a multi-line text field with Rich Text enabled. But set the Append Changes to Existing Text to No.

Create a new workflow

Now, you’ll need to open your list up in SharePoint Designer (if you haven’t already) and open your SharePoint site.

Go to the Workflows, and pick List Workflow from the ribbon. Select the list that you are setting up from the drop down menu.

Give your new workflow a name, such as Recent Comment.

Add new workflow

Add a Condition to your workflow

Next, add the following (or equivalent) condition from If current item field equals value.

new workflow condition

Set the field operand to your Comments field. Click on field and select Comments from the window.

Set the equals operator to matches regular expression.

Set the value operand to “.+” (without the quotes). This is a regular expression. The period (“.”) is saying match a character – any character. The “+” is saying there must be at least one. So, this is only matching when a Comments field has a text entry.

Add an Action to your workflow

Next, add an Action below your Condition. Choose Set field in current item.

Set the field operand to Most Recent Comments. Click on field and select Most Recent Comments from the window.

Set the value operand to be your Comments field.

Make sure your Action is nested under your Condition.

new workflow action

Set the main workflow settings

Finally, make sure your new work flow runs every time when an item is created or modified.

Click Workflow Setting up in the ribbon.

In the Start Option area, make sure that both Start workflow automatically when an item is created and Start workflow automatically when an item is changed are checked.

Wrap up

Click Publish in the ribbon. There, you’ve done it.

Once this is set up, you can add your mirror column to your views instead.

There you go.

keywords: sharepoint show most recent comment

40 thoughts on “Show the most recent comment from SharePoint text fields instead of “view items”

  • Christine

    I have encountered one issue with this solution and wonder if you can suggest a fix.
    When I edit an item to update a column and DO NOT update the Append-only Comments column, the workflow still updates the mirror column and it becomes blank (because there was no new Append-only Comments entry).
    I can avoid this glitch if I choose a Content Type that does not display the Apend-only Comments column. In that scenario, the last comment remains intact. But, this is not a good solution.

    My workflow looks like this:
    If CurrentItem:Append-only Development Comment matches regular expression .+
    Set Last Development Comment to [%Current Item:Append-only Development Comment]

    Can you tell me what I have done wrong? I am new to Designer.

    Thanks!
    Christine

    • Charlie

      The workflow step you showed looks correct. The “matches regular expression .+” ensures that it will only set the last comment if something was entered.

      I would check for another workflow or step that isn’t making this check and setting the mirror column. Also make sure that some whitespace isn’t a default value for the primary append-only column. That will make the workflow think there’s a change every time.

      Good luck,
      Charlie

  • Milap

    Nice solution but there is a drawback. This only shows the “most recent” comment as the solution title implies. What about a scenario where there may be multiple “recent” comments for a record? I could have 3, 4, 5 comments appended in a single day and need to be able to review the entire day’s history in the view. This fails that need. Any suggestions?

    • Charlie

      One thought is just to keep track (separate field) of the timestamp value for the comments being made. Concatenate the comments that occur ‘today’. Tomorrow, you’d wipe out the previous day’s comments and start accumulating anew (if you got a new comment) else the field would have the most recent day’s comments. I think that’s an approach that may be in the direction you’re looking for.

  • lanod

    Hi,

    I am attempting to do this in SP2013; however, my workflow cancels at Stage 1 and displays the below information.

    Any ideas?
    Thanks,
    Donal

    RequestorId: 8170c3a3-1e15-6c39-1778-69e770e3359e. Details: System.ArgumentNullException: Value cannot be null. Parameter name: input at System.Text.RegularExpressions.Regex.IsMatch(String input) at System.Activities.CodeActivity`1.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

    • Charlie

      All I can think of is just to make sure the value in the condition is .+ and the value in the set field action is the name of the comments field. The error message looks like one of them is missing. HTH

    • Matt

      Ianod, did you ever find a resolution to this issue? I am having the same issue, tried what Charlie suggested but that does not seem to be the problem. Some of my items are working properly but most suspend at stage 1

      • SImon

        Did anyone get to the bottom of this? also have the following error:

        RequestorId: 4423abc9-d92f-d0f9-0000-000000000000. Details: An unhandled exception occurred during the execution of the workflow instance. Exception details: System.ArgumentNullException: Value cannot be null. Parameter name: input at System.Text.RegularExpressions.Regex.IsMatch(String input) at System.Activities.CodeActivity`1.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation) Exception from activity IsEqualString DynamicActivity If Stage 1 Sequence Flowchart Sequence Recent Comment.WorkflowXaml_8fa852fe_5a87_4d2b_8272_3542f82ebfab

        Followed and re-followed the instructions to a tee….

    • Kiran

      If we are comparing Comment to “.+’ that means the workflow sees something in that column. And if it can, then why can’t we use that value directly instead of setting it to different field? I think the above Null error comes because we are using Comment in IF condition and it has no value. It is also failing for me.

    • Charlie

      Sure. Just create a String variable and concatenate the new text entered with the current date. You can get the current date from the Workflow Context list and use the date/time the workflow was started. That should give you a pretty close timestamp to the save of the record and initiation of the workflow.

  • Ani

    I set this up. But my workflow is not retrieving the comments into my mirror column. This is my logic

    If Current item: Comments is not empty
    Set Official Response/CommentsCP to Currentitem: Comments

  • hartski

    Hi – you missed a really important piece of info – this has to be set as a SP2010 workflow. SP 2013 wf does not work and creates the “Details: An unhandled exception occurred during the execution of the workflow instance….. ” error.

  • Hi Charlie, great work around. However, I’m not sure this works for SharePoint Online/365. Using SPD 2013, I got the workflow to work only after turning off “Automatically update the workflow status to the current stage name” (Ref: http://www.bornsolutions.com/Blog/Post/6/SharePoint-2013-Designer-Workflow-and-lists-with-versioning). However the workflow now only displays the first comment ever added and not any subsequent or more recent comment. Have an idea of what could be wrong?

  • Even though I have Current Item:Comments matches regular expression .+ I still get blanks written to the Most Recent Comment field if an item is updated but no comment is added. Any ideas? Running sharepoint 2013 with the 2010 workflow.

    • Charlie Nichols

      I’ve not seen that happen before. By chance is there something that adds a space or is there a default set where a space or other ‘whitespace’ character is present? *Any* character will match the regular expression as set up.

  • David

    I tried to set this up in SP 2013 with a SP 2010 workflow and also encountered the issue where it was blanking out. After some testing, I discovered that I had to set it to >=12 characters in order to function… but I can’t figure out where the system is hiding the other 11 characters in the blank text field. So strange!

    This works:
    If Variable: Current Status matches regular expression .{12,}
    Set Most Recent Status to [%Variable: Current Status%]

      • David

        Nick,

        I did that, but ended up with the same result. Unless I initiated the variable wrong…

        This is what I used to initiate it:
        Set Variable: Current Status to [%Current Item:Current Status%]

        Then used the code above.

    • Rachel

      David, thanks for posting this. It’s the only solution that solved the blanking out issue for me. I changed my regular expression to .{12,} as you suggested. I’m not using a variable and it works great. I have SP 2010.

  • Charlie/Nick/David,
    I am having the same issue of the last comment not showing.

    Nick- I tried your suggestion from May 2nd ’15 “This was strange, I ended up putting “Comments” in a variable first and then used that variable throughout the rest of the steps and it worked perfectly.” but do not understand what you mean by putting “Comments” in a variable first and then used that variable throughout the rest of the steps.

    Here is what I have:

    Step 1

    If Current Item: Comments matches regular expression .+
    Set Most Recent Comments to Current Item: Comments

    Any help would be greatly appreciated!

  • I tried this and it writes the value I entered for the SET step to the column and not the most recent entry.
    I have this:
    If Current Item:Progress matches regular expression.+
    Set Recent Progress to Progress

  • Julian

    This works for me. Thank you! How to make the “Most Recent Comments” read only? Currently, when a user creates or edit a record, he can add text both on the standard ‘Comments’ field as well as the new ‘Most Recent Comments’ field, which looks cumbersome.

    Thanks again,
    Julian

  • Mo

    I can’t get this to work on SharePoint Online (Office 365). If I use 2010 workflow, I get blanks. If I use 2013 workflow, it works the first time, and then the workflow gets suspended. Please hlep

    • Charlie Nichols

      I would take a look at the second column. Is ‘Append Changes to Existing Text’ set to ‘No’? It needs to be set to No for the second column.

  • This do not work in office365. I spent loong time and finally found out what the problem is
    “set field to Value” do not return anything if the Value is a comment with multiple lines. But a miracle happens if you change the setting on the workflow:

    You have to uncheck the “Automatically update the workflow status to the current stage name” . This is changed in the the workflow settings with SharePoint designer. Then it works. You can receive the latest comment just like described here in this fine post.

    But there are one more thing you have to do if you have SharePoint in Office365. Because the SharePoint designer do NOT work by default. no matter wjat you di the designer will not launch. That is until u make a another miracle. You have to install the Sharepoint online management shell. Then you have to issue the command

    Connect-SPOService
    then enter the URL
    Url: https://ellabxxxx-admin.sharepoint.com
    then u login when prompted
    Set-SPOSite -Identity https://ellabxxs.sharepoint.com -DenyAddAndCustomizePages $false

    Then it works 🙂

  • Russ Herald

    Also working with 2013, and can echo that you need to create an SP2010 style workflow, and ensure that you use matches regular expression (not equals) in the condition string.

  • Chet

    Hello,
    This sounds like a great soln for my problem too. I tried with the following using FLOW tool:
    ======================
    CONDITION:
    IS EQUAL TO Comments matches regular expression .+

    IF YES: UPDATE ITEM
    ==

    IF NO :
    ===============================
    Flow could be run successfully, but the value in “Most Recent Field” did not mirror the last “Update field” value. Instead, the “Most Recent Field” still remains blank after Flow execution.
    =======================
    Any suggestion?

Leave a Reply

Your email address will not be published. Required fields are marked *