How to work around the "append changes to existing text" feature of a multi-line textbox
Tags:
I love to use the multi-line text field in a SharePoint list or library. It is great for things like comments, status updates, notes and any other type of data that might require several lines of text. This column type even has a really cool feature that allows you to “Append Changes to Existing Text”. This feature will store ALL the changes to the field and display a historical list on the Edit or View pages.
Pretty cool! Right? Not so fast. This feature has some annoying drawbacks as well.
The Downside
There are two major side effects to turning the “Append Changes…” feature on.
1. It records all updates even blanks. If you edit the list item and only make a change to any field other than the multi-line text field it will store a blank in the history.
2. It will not display the current text in a list view. You only see a link that reads “View Entries…”.
A Common Approach
A common way I have seen this issue tackled is by creating a XSLT data view in SharePoint Designer. I will not cover this approach in detail, but the basic steps are:
1. Create a new Web Part page.
2. Add the desired list web part to the page.
3. In SharePoint Designer convert the web part into an XSLT Data View.
I do not care for this solution because it only address one of my gripes. It does show the most recent value entered into the multi-line textbox (Issue #2), but if that entry happens to be blank (Issue #1) it will display that as well. See the pictures above. Test Entry 2 displays the text that was entered, but Test Entry 1 shows blank. I want it to retain all the changes I have made and in the list view only display the last text that was entered.
My Solution
My approach utilizes a custom workflow to check for changes, but before we create the workflow we need to make some changes to your list.
1. Add a second multi-line textbox column. Call this one “Current Status” and make sure that the “Append Changes..” option is set to NO. Also, ensure that the “add to default view” is not checked.
2. Mark the new column as hidden. (This will prevent it from showing up in the Add / Edit / View pages)
a. Go to List Settings >> Advanced Settings and make sure the “Allow management of content types?” is YES.
b. In the List Settings page click on the content type to access its settings page.
c. Under the Column section click on “Current Status”.
d. Change the Column Settings to Hidden (Will not appear in forms).
3. Change the default view to show the “Current Status” column in place of the “Status” column.
a. Under the List Settings go to the Views section and click on the default view.
b. Uncheck “Status” and check the box next to “Current Status”. (You can also change the column order if needed)
Now that the list is configured properly we can create the new workflow.
1. Open SharePoint Designer to the desired site and click File >> New >> Workflow.
2. Name the workflow “Update Current Status” and select our list.
3. In the workflow start options ensure that only the boxes for “when a new item is created” and “whenever an item is changed” are checked.
4. Click Next.
5. On the next screen click Variables.
6. Add a new string variable named vRegExp.
7. In the Step Name field rename “Step 1” to “Initialize Variable”.
8. Leave the Conditions section blank.
9. Under Actions select “Build Dynamic String”.
10. Set our newly created variable “vRegExp” to the string “
.+
” (no quotes and it is case sensitive).
11. On the right hand column click the link to “Add workflow step”.
12. In the Step Name field rename “Step 2” to “Update Status”.
13. Under Condition select “Compare Test fields”.
14. Set the condition to “If Status matches regular expression Variable: vRegExp”.
15. Under the Actions select “Set Field in Current Item”.
16. Set the action to “Set Current Status to Status”.
17. Click Finish and exit out of SharePoint Designer.
Now try and update your list items and see what happens. If you enter a status then it will show up in the list view. If you update the item and don’t enter a status then the list view retains the last entry.
Conclusion
This solution uses the Status field with it’s “Append Changes…” feature in the Add / Edit / View forms, and uses the Current Status field for the list view to display the most recent update. A custom workflow was created in SharePoint Designer to check when the Current Status field needed to be updated.
**NOTE: It can take a few seconds for the workflow to run and update the field