Taming the Elusive “Calculated Column” – Referencing a Multiple Lines of Text Column With Append Text: Part 1
As a follow-up to a previous article I wrote on “Referencing Multiple Lines of Text” in a calculated column, and to address an issue brought up on the STP forums regarding how to use this technique with a “Multiple lines of Text” column that is set to “Append Changes to Existing Text” and how to view all of the versions (appended changes) in a regular list, I give you the following:
“How to reference a ‘Multiple Lines of Text’ column in a ‘Calculated Column’ to display a complete list of appended changes to all items on a list as a group – in 10 Easy Steps”.
Using the exact same technique I walked through in the previous article, we’ll create a custom list, add in a temporary column to set our calculated column reference, delete the column and recreate it as the appropriate type, then use some JavaScript to tie it all together with a custom view.
Step 1: Create your list
For this, I’ll just be using a custom list called “All Comments”.
In order for the “Append” part to work, we need to turn on “Versioning” in the list settings (Settings > List Settings > Versioning Settings > Choose “Create a version each time you edit an item in this list”).
Step 2: Create your temporary column
In order for you to be able to reference a “Multiple Lines of Text” column from a “Calculated Column”, you must fool the system into thinking its ok to do so.
The technique is simply to create a column with the name you intend to use in your formula making sure to leave all of its settings as default (leave it as a “Single Line of Text” type).
Create a new column called “Comments” leaving its setting as default.

Step 3: Add the Calculated Column
Since we now have our temporary column created, we can make a reference to it in our “Calculated Column” without any errors.
Create a new column called “Expanded Comments”, make it a “Calculated” type and add in the following formula:
=[Comments]

Step 4: Reset our Temporary column
Once we’ve made our reference, we can go back into the “Comments” column, delete it, and then recreate it as the type we really want to use.
Delete the “Comments” column then immediately recreate it (making sure that you are using the exact same name for the column), and this time set it as a “Multiple Lines of Text” type and choose the option to “Append Changes to Existing Text”.

Step 5: Test Round 1
To test this and make sure everything is working at this point, create a new item on the list and you should see something similar to this:

Step 6: The HTML Calculated Column
Notice that our calculated column, although displaying the correct information, is rather ugly at the moment with the added “div” tags surrounding the comment text?
To fix this, we’ll once again tap into Christophe’s “TextToHTML” script and add it in to a CEWP on the page.
On the view page, add in a CEWP and paste in the following script into its “Source Editor”:
/*> Text to HTML - version 2.1<br> Questions and comments: [email protected] */ function TextToHTML(NodeSet, HTMLregexp) { var CellContent = ""; var i=0; while (i < NodeSet.length){ try { CellContent = NodeSet[i].innerText || NodeSet[i].textContent; if (HTMLregexp.test(CellContent)) {NodeSet[i].innerHTML = CellContent;} } catch(err){} i=i+1; } } // List views var regexpTD = new RegExp("^\\s*<([a-zA-Z]*)(.|\\s)*/\\1?>\\s*$"); TextToHTML(document.getElementsByTagName("TD"),regexpTD); </script>
Note – although I have intentionally trimmed out some of the unused lines of script for this specific walkthrough, you can copy the entire script from Christophe’s site and use it as is – http://www.pathtosharepoint.com/HTMLcc
Immediately you should now see the comments being displayed appropriately:

Next, we need to add in a few edits to the item on the list in order to see how the system handles these “versions” of the text.
Edit the item and add in a few changes (saving after each one).
By default, the list itself will only display the most recent edit (standard behavior of “Versioning”), but for reference sake, click on the item to view its details then click on the “Version History” link to see all of our changes.


Although we “could” use this page as our method of seeing all of the comments, it’s not practical since it only lists out the versions for an individual item, not for a group of items.
Till next time…
– Dessie
Tomorrow Dessie will show us the "Magic" URL.
Dessie Lunsford
Points-of-Sharing
- Taming the Elusive "Calculated Column"
- EndUserSharePoint.com: Taming the Elusive "Calculated Column" - Customizing a Task List
- EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Task List (Part II)
- EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Task List (Part III)
- EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Task List (Part IV)
- EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Text and Data
- EndUserSharePoint.com: Taming the Elusive "Calculated Column" - Customizing a Contacts List (Part I)
- EndUserSharePoint.com: Taming the Elusive "Calculated Column" - Customizing a Contacts List (Part II-I)
- EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Contacts List (Part II-II)
- EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Contacts List (Part II-III)
- EndUserSharePoint.com: Taming the Elusive “Calculated Column” – Text and Data (Part III)
- EndUserSharePoint.com: Taming the Elusive “Calculated Column” – Text and Data (Part IV)
- EndUserSharePoint.com: Taming the Elusive “Calculated Column” – Text and Data (Part V)
- EndUserSharePoint.com: Taming the Elusive “Calculated Column” – Text and Data (Part VI)
- Taming the Elusive “Calculated Column” – Lookup and Reference
- Taming the Elusive “Calculated Column” - Logic
- Taming the Elusive “Calculated Column” - Logic - Part 1
- Taming the Elusive “Calculated Column” - Logic - Part 2
- Taming the Elusive “Calculated Column” - Logic - Part 3
- Taming the Elusive “Calculated Column” - Logic - Part 4
- Taming the Elusive “Calculated Column” - Logic - Part 5
- Taming the Elusive “Calculated Column” - Logic - Part 7
- Taming the Elusive “Calculated Column” - Logic - Part 6
- Taming the Elusive “Calculated Column” - Logic - Part 8
- Taming the Elusive “Calculated Column” - Logic - Part 9
- Taming the Elusive “Calculated Column” - Logic - Part 10
- Taming the Elusive “Calculated Column” - Date and Time - Part 1
- Taming the Elusive “Calculated Column” - Date and Time - Part 2
- Taming the Elusive “Calculated Column” - Date and Time - Part 3
- Taming the Elusive “Calculated Column” - Date and Time - Part 4
- Taming the Elusive “Calculated Column” - Referencing Multiple Lines of Text Column
- Taming the Elusive “Calculated Column” – Date and Time – Part 5
- Taming the Elusive “Calculated Column” – Date and Time – Part 6
- Taming the Elusive “Calculated Column” – Date and Time – Part 7
- Taming the Elusive "Calculated Column" - Referencing a Multiple Lines of Text Column With Append Text: Part 1
- Taming the Elusive "Calculated Column" - Referencing a Multiple Lines of Text Column With Append Text: Part 2
- Taming the Elusive "Calculated Column" - Referencing a Multiple Lines of Text Column With Append Text: Part 3
Hi Dessie:
Relative to Parts 1, 2 and 3, is this at all possible to add to a List in which the versioning has been ongoing for a year or more? In other words, can I retrofit your solution into my existing List?
Thanks-
Charlie Epes
Charlie,
I realize this is an old question, but since I never answered it…
Yes, you should be able to add this to an existing list without any problems.
- Dessie
Hi Dessie,
Thanks for the post. I have one doubt.
In the comments I’m able to see the different versions. But I don’t want the name who modified that one …
What I mean to say is,
Date Field and Comment is Required for me. i don’t need the name of the person who modified. Any Suggestions please.
Venkateswara,
Just remove the “Modified By” column from the view and you wont see who made the change.
If you read through the two remaining articles in this series you notice that I mention to remove any columns not needed – this is where you’d remove the modified by column if you dont want to see who made the last change.
- Dessie
In the views I can uncheck the ” Modified By ” Filed. But when click each item which is having different version… here you will find “Person Name (Date Modified) : Text”
Here I don’t want the “Person Name”…
Please let me know if my question is not clear …
Thanks,
Rao.
Can you provide the missing script???? On the view page, add in a CEWP and paste in the following script into its “Source Editor”:
I wen to the website that you have listed and it seems that all of the old data is gone.
I need to do what you have described here but without the script can not proceed.
Thank you.
Carole,
The post should be updated soon to include the missing script (it did used to be there, honest).
In the meantime, here’s the script itself:
Thanks so much for the quick reply. One more question. When I run the code the first time it works fine, but when another entry is made somewhere else in the form then the calc fields show 0. Not sure what I did wrong.
Caorle
Here you go Dessie… let me google that for you:
http://sp2010.pathtosharepoint.com/SharePoint-User-Toolkit/Downloads/Forms/AllItems.aspx
Glad I could be of help :-)
Mark
I realize I’m diverging from this post, but I’d like to do what you describe above, only using a “User or Group” column in my calculated column. Instead of displaying the name, however, it displays “16;#AD\username” – any way to trick Sharepoint into looking it up and displaying the actual person’s name?
The CEWP does not seem to strip out the html from displaying (the brackets and div and such)… I have been over it line by line and can’t figure out why – any ideas what I may be doing wrong? I downloaded the TexttoHTML Lite 2.1.1 from http://sp2010.pathtosharepoint.com/SharePoint-User-Toolkit/Downloads/Forms/AllItems.aspx, and after it initially didn’t work, trimmed out the Calendar Views portion (as that seemed to be the only change between the 2.1 you have listed here and 2.1.1).